Posts Tagged ‘startup’

Install and Run Multiple Tomcat and JAVA server instances on single Windows server Howto

Friday, June 17th, 2016

tomcat-windows-install-multiple-tomcats-on-one-single-windows-logo
I've had a task at my work place to install Multiple Tomcat servers on Windows 2012 Server R2 the task seems trivial however I've faced few minor issues and the few searches in Google returned very few articles discussing the topic and this give me the idea that it might be helpful to others to come up with my own article as this might save time for those Linux guys who need to install Multiple Tomcat instances on the same Windows server without spending too much time to dig into the arcane winblows.

I stumbled on some issues during installation  thus took the time to systemize below shortly how I managed to run 2 Tomcat servers on One Windows 2012 R2 machine.
 

First thing to do is to obtain latest compiled Tomcat server archive from Tomcat's official download page here.

Latest Tomcat stable release as of time of writting this article is 7.0.69, so I've downloaded 64 Bit archive (as the server is running X64 Operating system) and unarchived it twice on the Install server under 2 separate directory locations under:

 

D:\Tomcat\Tomcat_Instance-1

 

and

 

D:\Tomcat\Tomcat_Instance-2

 


Copy of the 7.0.69 X86 tomcat zip archive is here and X64 bit tomcat 7.0.69 is here

Once the files are properly untarred I also needed to download also Java as the WAR application supposed to run on the Windows machine had as requirement Java JDK 8.

Downloading Java is a trivial task, however in my case the server used to be in DMZ (Demiliterized Zone) / Firewalled network and hence instead of using the default Java installer provided from Oracle website which is trying to download from Internet, I had instead to download and use the Offline current JAVA 8u91 version.
Just for sake of some convenience I've made a mirrored version of X86 JAVA 8 (8u91) is here and JAVA 8u91 X64 version here

 

install-Java-JDK-and-JRE-8-on-Microsoft-Windows-howto

JAVA JDK install is a trivial task just run the isntaller set the proper locations initially for JDK base folder in my case this was:

 

D:\Java\jdk

 

and later throughout during install, I was asked also to fill in full path location for JRE, in my case this was

 

D:\Java\jre

 

It was a little bit surprising for me that JRE install path had to be entered and because I was not careful enough I had twice entered the same path for both JRE and JDK, i.e. entered on both prompts:

 

D:\Java

 

This caused issues and a messed Java install but I realized that after the 3rd re-install of Java when I decided to also read instead of by habit click Next / Next and Complete the install as used to be in the good old days of Windows XP and Windows 98 🙂

Once Java set up correctly I've tested it with:

 

C:\Users\georgi> java -version

 

 

test-java-version-on-microsoft-windows-command-howto-screenshot


It is also necessery to set properly following 2 JAVA command line environment variables:
 

JAVA_HOME
JRE_HOME


On the logged in user Environment Variables with which Tomcat will be running on how to do that check my previous article how to add Environment Variables on Windows
 

 

Make sure you have the following 2 environment variables set upped:

 

JAVA_HOME=D:\Java\jdk

 

 

JRE_HOME=D:\Java\jre

 


For one time set (assuming Java is installed) under D:Javajre and D:Javajdk, you will need to type in command prompt:

set JAVA_HOME=D:\Java\jdk

set JRE_HOME=D:\Java\jre

Once assured Java is running fine I proceeded to run the Tomcat serevrs, in order to make them working it was necessery to change all coinciding Port names under:

 

conf/server.xml

 

because if there are coinciding ports (assuming that like me you're trying to run both Tomcat under the same IP address), the servers will fail to run because they're trying to bind under the same Port TCP addresses.

Assuming that the tomcat archive files are copied from .zip into D:TomcatTomcat_Instance-1 and D:TomcatTomcat_Instance-2 folders and you have in each of the 2 the following directory structure:

 

    /bin : This directory contains the startup and shutdown scripts for both Windows and Linux.
    /conf : This directory contains the main configuration files for Tomcat. The two most important are the server.xml and the global web.xml .
    /server : This directory contains the Tomcat Java Archive files.
    /lib : This directory contains Java Archive files that Tomcat is dependent upon.
    /logs : This directory contains Tomcat’s log files.
    /src : This directory contains the source code used by the Tomcat server. Once Tomcat is released, it will probably contain interfaces and abstract classes only.
    /webapps : All web applications are deployed in this directory; it contains the WAR file.
    /work : This is the directory in which Tomcat will place all servlets that are generated from JSPs. If you want to see exactly how a particular JSP is interpreted, look in this directory.

 

You will need to edit server.xml in both of the Tomcats and make sure the configuration for ports is not coinciding, i.e., I've changed the following configurations for Tomcat_Instance-2 installation:

 

    Connector Port : This is the port where Apache Tomcat listen for the HTTP requests. Default port is 8080, I've changed this to 8089 for second Tomcat server
    Shutdown Port : This port is used when we try to shutdown the Apache Tomcat Server. Default port is 8005 so changed that to 8006 in Tomcat_Instance-2
    AJP (Apache JServ Protocol) Connector Port : The Apache JServ Protocol (AJP) is a binary protocol that can conduct inbound requests from a web server through to an application server that sits behind the web server.
I've commented out the configuration for AJP completely and used for my custom needs the following server.xml configuration:

<Connector port="11111" address="10.251.27.24" protocol="AJP/1.3" enableLookups="false"/>

    Redirect Port : Any redirection happening inside Apache Tomcat will happen through this port. In Apache TOMCAT there are two instance where redirect Port is mentioned. First one is for the Apache TOMCAT server and other one is for the AJP port. Default here is port 8443 so changed that one to to listen to 8444 instead.


Another thing necessery to do is to create setenv.bat file under both D:\TomcatTomcat_Instance-1\bin and D:\Tomcat\Tomcat_Instance-2\bin with following content:
 

set JRE_HOME=D:\java\jre
set JAVA_HOME=d:\java\jdk
exit /b 0

 


The quickest way to do it without bothering with Notepad text editor is by issuing:
 

 

cd tomcat\Tomcat_Instance1\bin
echo set JRE_HOME=D:\java\jre > setenv.bat
echo set JAVA_HOME=D:javajdk >> setenv.bat

 

cd tomcat\Tomcat_Instance2\bin
echo set JRE_HOME=D:\java\jre > setenv.bat
echo set JAVA_HOME=D:\java\jdk >> setenv.bat


The setenv.sh is a standard variables file read by Tomcat on Instance start up time
 

Next part of Tomcat installation is to install each of the 2 instances after defining CATALINA_BASE to point to first and second Tomcat instance directories, e.g open a Command Prompt (cmd.exe) and run there:

 

set CATALINA_BASE=D:\Tomcat\Tomcat_Instance-1

C:|> d:

D:|> cd Tomcat\Tomcat_Instance-1\bin
 

 

D:Tomcat\Tomcat_Instance-1\bin> service install Tomcat_Instance-1


You will get output like:

 

Using CATALINA_BASE:   " D:\Tomcat\Tomcat_Instance-1"
Using CATALINA_HOME:   " D:\Tomcat\Tomcat_Instance-1"
Using CATALINA_TMPDIR: " D:\TomcatTomcat_Instance-1\temp"
Using JRE_HOME:        "D:\java\jre"
Using CLASSPATH:       "D:\Tomcat\Tomcat_Instance-1\bin\bootstrap.jar; D:\Tomcat\Tomcat_Instance-1\bin\tomcat-juli.jar"

 


Then for the second Tomcat server instance run in command prompt:
 

 

set CATALINA_BASE=D:\Tomcat\Tomcat_Instance-2

d:

cd Tomcat\Tomcat_Instance-2\bin
service install Tomcat_Instance-2

Using CATALINA_BASE:   " D:\Tomcat\Tomcat_Instance-2"
Using CATALINA_HOME:   " D:\Tomcat\Tomcat_Instance-2"
Using CATALINA_TMPDIR: " D:\Tomcat\Tomcat_Instance-2\temp"
Using JRE_HOME:        "D:\java\jre"
Using CLASSPATH:       "D:\Tomcat\Tomcat_Instance-1\bin\bootstrap.jar; D:\TomcatTomcat_Instance-2\bin\tomcat-juli.jar"

windows-running-two-tomcat-instances-on-the-same-single-server-screenshot


Here is all the service.bat batch file parameters:

 

D:\Tomcat\Tomcat_Instance-11\bin>service.bat /
?
Unknown parameter "/?"

 

Usage: service.bat install/remove [service_name] [/user username]


To test both Tomcat servers where they run simultaneously without issues, I run in 2 separate command prompts – opened (cmd.exe) two times and run in each of them:

What this little command does is uses Tomcat7.exe command to Add / Remove / Modify the Tomcat instance into Windows Services, the same can be happily done also with the good old
sc (service configure) windows command.

 

D:

cd Tomcat\Tomcat_Instance-1\bin\startup.bat

D:

cd Tomcat\Tomcat_Instance-2\bin\startup.bat
 

Both executed without errors in command line and to stop them I've pressed the usual CTRL+C.
To make sure once again both server instances ran wihtout errors, I've checked in D:TomcatTomcat_Instance-{1,2}logs/catalina*.log and in both of them all looked fine.
Another good check if you want to be 10000% sure Tomcat is running is to look up for Tomcat listening on above configured ports, for example run below in cmd:

 

D:Tomcat> netstat -a|findstr "8080"


I've also used the 2 following command to set up proper Services description for both of services:
 

 

D:\Tomcat\Tomcat_Instance-1\tomcat7 //US//Tomcat_Instance1 –Description="Apache Tomcat Server – Tomcat-Instance1.my-site.com"

D:\Tomcat\Instance_Instance-2\tomcat7 //US//Tomcat_Instance2 –Description="Apache Tomcat Server – Tomcat-Instance2.my-site.com "
 

 

A very helpful resource during the Apache (Windows Service) instance install / setup /modification that helped me is on Tomcat's official site here
 

N! B! Very important note to make here for anyone experiencing strange issues when trying to add multiple issues is below:

I've experienced some issues while trying to add the 2 Tomcat servers into Windows services initially with tomcat7.exe command like so:

Trying installing Tomcat71 service with cmd:
 

 tomcat7 //IS//Tomcat71 –DisplayName="Apache Tomcat 7" ^
     –Install="D:\Tomcat\Tomcat_Instance-1\bin\tomcat7.exe" –Jvm=auto ^
     –StartMode=jvm –StopMode=jvm ^
     –StartClass=org.apache.catalina.startup.Bootstrap –StartParams=start ^
     –StopClass=org.apache.catalina.startup.Bootstrap –StopParams=stop

 

And Tomcat72 instance with cmd:
 

 tomcat7 //IS//Tomcat71 –DisplayName="Apache Tomcat 7" ^
     –Install="D:\Tomcat\Tomcat_Instance-2\bin\tomcat7.exe" –Jvm=auto ^
     –StartMode=jvm –StopMode=jvm ^
     –StartClass=org.apache.catalina.startup.Bootstrap –StartParams=start ^
     –StopClass=org.apache.catalina.startup.Bootstrap –StopParams=stop

 

I've tried multiplet imes to Add and remove the Tomcat71 and Tomcat72 Windows service names (with) Tomcat DS (Delete Service)
 

tomcat7 //DS/Tomcat71
tomcat7 //DS/Tomcat72


And strangely the two instances were continuously crashing when I tried to start them (with Properties button and Start instruction) from Windows Task Manager (taskmgr.exe) -> Services

Finally I realized the issue is caused by some problems that somehow occured with Windows Service Names Tomcat71 and Tomcat72 by simply readding the two instances under another name the instances stopped crashing and all worked thanks to help of colleague Anatoliy who pointed me tot he problem by trying to install his own instances under a different service name).

Thanks God finally the 2 instances run fine !

 

How to set applications (programs) Autorun on XFCE in Xubuntu Linux

Monday, January 16th, 2012

I needed to set TeamViewer to autorun, each and every startup on one Xubuntu Linux

Xubuntu is running by default with Xfce 4 . Xfce is a sort of a very liteweight GNOME like graphical environment.

In Gnome the way that is through invoking the gnome-session-manager .

In Xfce the command is almost analogous doing changes is done by running:

user@xubuntu:~$ xfce4-session-manager

XFce session manager Xubuntu Linux screenshot
Further on simply use the Add button to add applications to load each time user (opens xfce session) / logs in.
Cheers 😉

Geki2 and Geki3 a Xenon 2 Megablast like games for GNU / Linux and FreeBSD

Thursday, December 22nd, 2011

Do you remember the old arcade spaceship shooter Xenon 2 Megablast? I do 😉 For all those who are too young to remember, here are two screenshots:

Xenon2 Main game Screen PC DOS ver

Xenon 2 megablast PC DOS level screenshot

Even though Xenon 2 Megablast original can now be played using dosbox DOS emulator. Its interesting to mention I've found two Linux games that more or less can be qualitified to resemble Xenon 2.
The games are Native Free Software games and existing in package repositories of most Linux distributions and *BSD port trees.

Geki 2 and Geki 3 are of a less quality to Xenon but still, the game experience is nice and is among the Arcade shooter games to bring you fun in the boring days if you're on GNU / Linux or FreeBSD Free OS platforms.

Installing Geki2 and Geki3 on Debian and Ubuntu Linux is standard with apt:

debian:~# apt-get install geki2 geki3
...

On Debian GNU / Linux , after installed the games would not create GNOME Applications -> Games -> game startup shortcuts, however the game startups will get added in GNOME Applications Menu under:

Applications -> Debian -> Games -> Action -> Geki 2
and
Applications -> Debian -> Games -> Action -> Geki 3

The games can be launched also manually with commands:

geki2

Geki 2 Linux Xenon 2 like game Main Menu

or

geki3
Geki3 gameplay screenshot Debian Linux

Geki 2 is a way closer to Xenon 2 as it has similar look and feel and the same vertical direction the spaceship is navigated.
In Geki 3 still the shoot 'em' up spaceship like arcade is present, however instead of penguin you have to fly a flying penguin, as well as the spaceship move direction is horizontal.

 Both the games have the same sound and music effects. The game music and effects are not of top quality but are not bad. In general  the games surely gives some of the arcade atmosphere.

Geki 2 GNU Linux Xenon 2 like vertical shooter arcade
Geki 2 Xenon 2 Megablast like on Debian Linux

In the tradition of the arcade games at the end of each level in both games you face the Level Boss Enemy, you should destroy.

Geki3 Level boss Debian Linux Screenshot
As you can see in below's screenshot the overall graphics of GEKI 3 is poorer while compared to GEKI 2

still GEKI 2 gampley is fun and addictive and I would say not less enjoyable than GEKI 2.
 At times I even think that Geki 3 is more fun because it is more dynamic.

 Maybe other reason, why I enjoyed more Geki 3 is also the fact that Geki 2 is a way harder to play. Dying only 3 times in the game you get  GAME OVER  and the next game you're started from the beginning of the same level you died in …

Geki2 Linux different shooting Screenshot

 Something really annoying that affects both the games; there is no option to play them in Fullscreen mode! ARGH!

Game controls for Geki2 and Geki3 are identical as follows:

Up - Arrow up key
Down - Down arrow key
Right - Right arrow key
left - Left arrow key
Shoot - z or Space
Pause - s

Geki2 and Geki3 are fun and can kill some time, but definitely aren't that (professional) as other spaceship shoot'em'up arcades for Linux and BSD. Games like Starfighter , Critical Mass or  powermanga .
 Lest that they are two worthy to install and play on your Free Software OS.