0

I have 2 Tomcat Servers in different directory D and E.I want to start these Servers simultaneously.

What I did:

1st Approach:

1)By reading on various sites I found to change the port no of the tomcat which i did.

2)In my Catalina_Home folder I have path value of CATALINA_HOME=D:\tomcat\apache-tomcat-7.0.70.

When I start Tomcat from drive E.I get an error in Tomcat of Drive E which is

INFO: Server startup in 105794 ms
Aug 22, 2016 10:37:29 AM org.apache.catalina.core.StandardServer await
SEVERE: StandardServer.await: create[localhost:8005]:
java.net.BindException: Address already in use: JVM_Bind
    at java.net.DualStackPlainSocketImpl.bind0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketBind(Unknown Source)
    at java.net.AbstractPlainSocketImpl.bind(Unknown Source)
    at java.net.PlainSocketImpl.bind(Unknown Source)
    at java.net.ServerSocket.bind(Unknown Source)
    at java.net.ServerSocket.<init>(Unknown Source)
  at org.apache.catalina.core.StandardServer.await(StandardServer.java:444)
    at org.apache.catalina.startup.Catalina.await(Catalina.java:781)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:727)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:428)

Aug 22, 2016 10:37:29 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-apr-8080"]
Aug 22, 2016 10:37:29 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-apr-8009"]
Aug 22, 2016 10:37:29 AM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Aug 22, 2016 10:37:29 AM org.apache.catalina.loader.WebappClassLoaderBase  clear ReferencesThreads
SEVERE: The web application [/Subs_Engine] appears to have started a thread name
d [Abandoned connection cleanup thread] but has failed to stop it. This is  very
likely to create a memory 

2nd Approach:

As said I tried the following things in cmdPrompt for tomcat defined in E Drive

@Edit enter image description here And I get the following prompt saying

enter image description here

3rd Approach:

a)Port Nos I have verified.They both are different in each directory of Server.

b)I have opened startup.bat and have replaced CATALINA_HOME with CATALINA_HOME_E.

c)I have set CATALINA_HOME_E in System and User defined environment variable as E:\apache-tomcat-7.0.70.

And in System variables the path variable I have added is %CATALINA_HOME_E%\lib;

Now the tomcat got started but I am getting the error:

INFO: Server startup in 105794 ms
Aug 22, 2016 10:37:29 AM org.apache.catalina.core.StandardServer await
SEVERE: StandardServer.await: create[localhost:8005]:
java.net.BindException: Address already in use: JVM_Bind
    at java.net.DualStackPlainSocketImpl.bind0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketBind(Unknown Source)
    at java.net.AbstractPlainSocketImpl.bind(Unknown Source)
    at java.net.PlainSocketImpl.bind(Unknown Source)
    at java.net.ServerSocket.bind(Unknown Source)
    at java.net.ServerSocket.<init>(Unknown Source)
  at org.apache.catalina.core.StandardServer.await(StandardServer.java:444)
    at org.apache.catalina.startup.Catalina.await(Catalina.java:781)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:727)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:428)

The reason I see for this error is that Tomcat I am starting from E drive is starting from D drive . I saw the port on which I am running Tomcat which is 7080 for http using >netstat -ano|find ":7080"

I didn't find anything running. So,I have cofigured the path settings wrong.

Am I doing it right for this approach?

Can anyone guide me why how to correct this?

  • The stack trace mentions of a port conflict. Can you check if 8085 is an available port ? is the Tomcat start-server script in the path ? If so which one is picked up ? May be it is a good idea to set the path on the command line where you are launching the start server for Tomcat and try executing again so that you can avoid a conflict ? – Ramachandran.A.G Aug 22 '16 at 05:24
  • 1
    You have to change the configuration, in a way that each tomcat listen on a different port. Not online the http, but all other services that expose on a tcp port. – Mario Santini Aug 22 '16 at 05:26
  • @RamachandranGA 8085 or 8080 is an available port? – user6389648 Aug 22 '16 at 05:30
  • 1
    Note that the RUNNING.TXT file contains an advanced section that describes how to setup multiple tomcat instances on a single host. – Claudio Corsi Aug 22 '16 at 05:39
  • @MarioAlexandroSantini Can you please explain in more detail?I have not understood. – user6389648 Aug 22 '16 at 05:58
  • 1
    on approach 2, the way you start the server is not suitable for the `set` command, AFAIK , using `set` will set the variable to the current session, not global, so using `start startup.bat` will open new cmd which means a new session that DOES NOT have the variable defined. so use same approach but when starting server just type `startup.bat` and hit enter button – Yazan Aug 22 '16 at 07:55

3 Answers3

2

Here is what you should try

a) Set different ports for both the tomcat instances. This is done by editing the server.xml and ensuring that there is no port conflict. In port selection ensure that you have no "other" applications listening in (Different application lets say listening in on 8085 - non tomcat may be for example)

b) Do not set a global path for startServer.bat or have both the startServer.bat in the command line or user profile. Everytime you start startServer on the command line ensure you set the path then and there. Since you mention D and E , i assume windows here.

On the command line

a) cd ... b) SET CATALINA_HOME=D:...\TomcatOnD\ c) SET PATH=%PATH%;D:...\TomcatOnD\bin d)startServer.bat

do the same thing , with different path for the tomcat on E:\

see if the servers boot up. Hopefully they should :)

Ramachandran.A.G
  • 4,788
  • 1
  • 12
  • 24
  • Note , catalina_home does not point to the bin directory , but tothe top level folder of the install , i think it must be E:\apache-tomcat-7.0.70\bin>set CATALINA_HOME=E:\apache-tomcat-7.0.70\; – Ramachandran.A.G Aug 22 '16 at 06:31
  • You should check this question as to how to set CATALINA_HOME , change values in accordance with how the installation is done : https://stackoverflow.com/questions/14579661/how-to-set-catalina-home-variable-in-windows-7. AFAIK , you need not have the ; (semi colon) at the end of a singular property such as catalina_home – Ramachandran.A.G Aug 22 '16 at 06:52
2

what you have to do is

  1. use different port for the second server
  2. use different catalina for the second server

i will leave first tomcat as is, the one on D: the one we will change is the E:

1- open conf/server.xml for tomcat which is installed on E: find the port config element (tag) named Connector change the port to any unused port, ex 9090

<Connector port="9090" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

make sure the one on D: does not use the same port too.

2- open the bin/startup.bat for server installed on E: and replace all CATALINA_HOME to CATALINA_HOME_E you can use different name if you want.

3- add new System Enviroment key CATALINA_HOME_E make it point to E:\apache-tomcat-7.0.70\bin

now you can start both servers using startup.bat files located on E:\apache-tomcat-7.0.70\bin and D:\apache-tomcat-7.0.70\bin

i have used this method years ago on a windows, though it is not tested recently. but i assume it will still work

Don't add E:\apache-tomcat-7.0.70\bin or D:\apache-tomcat-7.0.70\bin to PATH as when you do so, if you type startup in cmd it may start the same instance twice. instead navigate to the folder and start the bat file

if you need to add to PATH you need to rename the startup files, so they end like this startupd.bat and startupe.bat so no mixing will occur when you start servers using command.

EDIT: as per your feedback on this method tomcat uses a connection -i think- it's for some internal signaling and communication, may be to send the shutdown signal to the server?! which is on port 8005 by default you need to set a new port on the E: tomcat, it's on server.xml conf file tag SERVER <Server port="8005" shutdown="SHUTDOWN" set a new port, may be 8006

Yazan
  • 6,074
  • 1
  • 19
  • 33
  • @user6389648 did you try this method?? – Yazan Aug 22 '16 at 07:53
  • @user6389648 sorry, did not see that, i have updated my answer too, hope this will fix the issue. check below EDIT: section – Yazan Aug 22 '16 at 08:26
  • The port for ShutDown, AJP and HTTP are all different in both directory.Still Tomcat Defined in drive e is using the same port 8005 which is shutdown port for drive tomcat in drive d. – user6389648 Aug 22 '16 at 08:58
  • @user6389648 did you change the one in E: to 8006? – Yazan Aug 22 '16 at 09:06
1

Check the configuration file server.xml
The ports defined in
<Connector connectionTimeout="20000" port="9090" protocol="HTTP/1.1" redirectPort="8443"/>
and
<Connector port="9009" protocol="AJP/1.3" redirectPort="8443"/>

should be different for each tomcat instance.

A Joshi
  • 151
  • 1
  • 6