Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
509 views
in Technique[技术] by (71.8m points)

tomcat - java.net.BindException: Address already in use: JVM_Bind

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 have:

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

but when I run the first tomcat the console say

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 run good, i using the command netstate -tnao and i verified that the ports are free

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...