1

I have 2 Tomcats running in my server: one Tomcat 7 and the other is Tomcat 8.

The configuration file server.xml for the first is:

<Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443" />
             ...
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

In the second Tomcat I have:

<Connector port="8080" protocol="HTTP/1.1"
            connectionTimeout="20000"
            redirectPort="8443" />
            ...
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

When I run the first Tomcat the console shows the following:

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:420)
at org.apache.catalina.startup.Catalina.await(Catalina.java:713)
at org.apache.catalina.startup.Catalina.start(Catalina.java:659)
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:351)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)

But the second runs good.I'm using the command netstate -tnao and see that the ports are free.

2 Answers 2

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

8080 is the port number on which server will run. Only one server (which you will start first) would run. Other one will throw Jvm Bind Exception.

So, change the port number so that they are unique.

One you run first server then use netstat command to see the ports which are in use.

Sign up to request clarification or add additional context in comments.

Comments

1

You need to have different ports for the tomcat instance including but not limited to the connector port, ajp port, shutdown port. And once you have that the error would go away.

However it is good practice to have the same tomcat binary being used to run multiple tomcat instances using the CATALINA_BASE variable. More details are in the link below. See the section on running multiple instances. Also note that this same RUNNING.txt file would also be in the tomcat binaries and you can also review it there.
http://tomcat.apache.org/tomcat-7.0-doc/RUNNING.txt

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.