Tomcat startup, 8080 address already in use

ぃ、小莉子 提交于 2019-12-03 04:14:28

问题


The setup is:

  • Amazon EC2
  • Tomcat (with secure forwarding to 8443)
  • Apache 2.2

I run the shutdown.sh, and I get no errors.

BUT when I try to runt the startup.sh I get this error:

07-Nov-2011 17:40:40 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/lib/i386/client:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/lib/i386:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/../lib/i386:/usr/java/packages/lib/i386:/lib:/usr/lib
07-Nov-2011 17:40:41 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
07-Nov-2011 17:40:41 org.apache.coyote.http11.Http11Protocol init
SEVERE: Error initializing endpoint
java.net.BindException: Address already in use <null>:8080
        at org.apache.tomcat.util.net.JIoEndpoint.init(JIoEndpoint.java:549)
        at org.apache.coyote.http11.Http11Protocol.init(Http11Protocol.java:176)
        at org.apache.catalina.connector.Connector.initialize(Connector.java:1022)
        at org.apache.catalina.core.StandardService.initialize(StandardService.java:703)
        at org.apache.catalina.core.StandardServer.initialize(StandardServer.java:838)
        at org.apache.catalina.startup.Catalina.load(Catalina.java:538)
        at org.apache.catalina.startup.Catalina.load(Catalina.java:562)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:261)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.net.BindException: Address already in use
        at java.net.PlainSocketImpl.socketBind(Native Method)
        at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:336)
        at java.net.ServerSocket.bind(ServerSocket.java:336)
        at java.net.ServerSocket.<init>(ServerSocket.java:202)
        at java.net.ServerSocket.<init>(ServerSocket.java:158)
        at org.apache.tomcat.util.net.DefaultServerSocketFactory.createSocket(DefaultServerSocketFactory.java:50)
        at org.apache.tomcat.util.net.JIoEndpoint.init(JIoEndpoint.java:538)
        ... 12 more
07-Nov-2011 17:40:41 org.apache.catalina.core.StandardService initialize
SEVERE: Failed to initialize connector [Connector[HTTP/1.1-8080]]
LifecycleException:  Protocol handler initialization failed: java.net.BindException: Address already in use <null>:8080
        at org.apache.catalina.connector.Connector.initialize(Connector.java:1024)
        at org.apache.catalina.core.StandardService.initialize(StandardService.java:703)
        at org.apache.catalina.core.StandardServer.initialize(StandardServer.java:838)
        at org.apache.catalina.startup.Catalina.load(Catalina.java:538)
        at org.apache.catalina.startup.Catalina.load(Catalina.java:562)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:261)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
07-Nov-2011 17:40:41 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8443
07-Nov-2011 17:40:41 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 615 ms
07-Nov-2011 17:40:41 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
07-Nov-2011 17:40:41 org.apache.catalina.core.StandardEngine start

INFO: Starting service Catalina
07-Nov-2011 17:40:41 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.33
07-Nov-2011 17:40:41 org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor host-manager.xml
07-Nov-2011 17:40:41 org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor manager.xml
07-Nov-2011 17:40:41 org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive test.war
log4j:WARN No appenders could be found for logger (StackTrace).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
log4j:ERROR Error initializing log4j: grails/plugins/springsecurity/SecurityConfigType : Unsupported major.minor version 51.0 (unable to load class grails.plugins.springsecurity.SecurityConfigType)
java.lang.UnsupportedClassVersionError: grails/plugins/springsecurity/SecurityConfigType : Unsupported major.minor version 51.0 (unable to load class grails.plugins.springsecurity.SecurityConfigType)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:186)
        at Config.class$(Config.groovy)
        at Config.$get$$class$grails$plugins$springsecurity$SecurityConfigType(Config.groovy)
        at Config.run(Config.groovy:116)
07-Nov-2011 17:40:43 org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
07-Nov-2011 17:40:43 org.apache.catalina.core.StandardContext start
SEVERE: Context [/test] startup failed due to previous errors
07-Nov-2011 17:40:43 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [/test] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
07-Nov-2011 17:40:43 org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive browser.war
07-Nov-2011 17:40:43 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory examples
07-Nov-2011 17:40:43 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory ROOT
07-Nov-2011 17:40:43 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory docs
07-Nov-2011 17:40:43 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
07-Nov-2011 17:40:43 org.apache.coyote.http11.Http11Protocol start
SEVERE: Error starting endpoint
java.net.BindException: Address already in use <null>:8080
        at org.apache.tomcat.util.net.JIoEndpoint.init(JIoEndpoint.java:549)
        at org.apache.tomcat.util.net.JIoEndpoint.start(JIoEndpoint.java:565)
        at org.apache.coyote.http11.Http11Protocol.start(Http11Protocol.java:203)
        at org.apache.catalina.connector.Connector.start(Connector.java:1095)
        at org.apache.catalina.core.StandardService.start(StandardService.java:540)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)

 at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.net.BindException: Address already in use
        at java.net.PlainSocketImpl.socketBind(Native Method)
        at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:336)
        at java.net.ServerSocket.bind(ServerSocket.java:336)
        at java.net.ServerSocket.<init>(ServerSocket.java:202)
        at java.net.ServerSocket.<init>(ServerSocket.java:158)
        at org.apache.tomcat.util.net.DefaultServerSocketFactory.createSocket(DefaultServerSocketFactory.java:50)
        at org.apache.tomcat.util.net.JIoEndpoint.init(JIoEndpoint.java:538)
        ... 12 more
07-Nov-2011 17:40:43 org.apache.catalina.core.StandardService start
SEVERE: Failed to start connector [Connector[HTTP/1.1-8080]]
LifecycleException:  service.getName(): "Catalina";  Protocol handler start failed: java.net.BindException: Address already in use <null>:8080
        at org.apache.catalina.connector.Connector.start(Connector.java:1102)
        at org.apache.catalina.core.StandardService.start(StandardService.java:540)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
07-Nov-2011 17:40:43 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8443
07-Nov-2011 17:40:43 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
07-Nov-2011 17:40:43 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/120  config=null
07-Nov-2011 17:40:43 org.apache.catalina.startup.Catalina start
INFO: Server startup in 2286 ms
07-Nov-2011 17:42:14 org.apache.coyote.http11.Http11Protocol pause
INFO: Pausing Coyote HTTP/1.1 on http-8080
07-Nov-2011 17:42:14 org.apache.coyote.http11.Http11Protocol pause
INFO: Pausing Coyote HTTP/1.1 on http-8080
07-Nov-2011 17:42:14 org.apache.coyote.http11.Http11Protocol pause
INFO: Pausing Coyote HTTP/1.1 on http-8443
07-Nov-2011 17:42:15 org.apache.catalina.core.StandardService stop
INFO: Stopping service Catalina
07-Nov-2011 17:42:15 org.apache.coyote.http11.Http11Protocol destroy
INFO: Stopping Coyote HTTP/1.1 on http-8080
07-Nov-2011 17:42:15 org.apache.coyote.http11.Http11Protocol destroy
INFO: Stopping Coyote HTTP/1.1 on http-8080
07-Nov-2011 17:42:15 org.apache.coyote.http11.Http11Protocol destroy
INFO: Stopping Coyote HTTP/1.1 on http-8443

I've tried commands such as netstat -aon | grep 8080 I've tried ps -efl | grep java and killing that process using kill <pid> 9 pkill java and so on...

This is what netstat -aon

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       Timer
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      off (0.00/0/0)
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      off (0.00/0/0)
tcp        0      0 10.226.122.156:22           109.58.56.15:49215          ESTABLISHED keepalive (5354.40/0/0)
tcp        0      0 :::80                       :::*                        LISTEN      off (0.00/0/0)
tcp        0      0 :::22                       :::*                        LISTEN      off (0.00/0/0)
udp        0      0 0.0.0.0:68                  0.0.0.0:*                               off (0.00/0/0)
udp        0      0 10.226.122.156:123          0.0.0.0:*                               off (0.00/0/0)
udp        0      0 127.0.0.1:123               0.0.0.0:*                               off (0.00/0/0)
udp        0      0 0.0.0.0:123                 0.0.0.0:*                               off (0.00/0/0)
udp        0      0 ::1:123                     :::*                                    off (0.00/0/0)
udp        0      0 fe80::1031:3cff:fe0:123     :::*                                    off (0.00/0/0)
udp        0      0 :::123                      :::*                                    off (0.00/0/0)
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node Path
unix  2      [ ACC ]     STREAM     LISTENING     2337   @/tmp/fam-root-
unix  2      [ ACC ]     STREAM     LISTENING     409    @/com/ubuntu/upstart
unix  2      [ ]         DGRAM                    644    @/org/kernel/udev/udevd
unix  8      [ ]         DGRAM                    1513   /dev/log
unix  3      [ ]         STREAM     CONNECTED     38302
unix  3      [ ]         STREAM     CONNECTED     38301
unix  2      [ ]         DGRAM                    38297
unix  2      [ ]         DGRAM                    22149
unix  3      [ ]         STREAM     CONNECTED     2340   @/tmp/fam-root-
unix  3      [ ]         STREAM     CONNECTED     2339
unix  2      [ ]         DGRAM                    1998
unix  2      [ ]         DGRAM                    1918
unix  2      [ ]         DGRAM                    1895
unix  2      [ ]         DGRAM                    1819
unix  3      [ ]         DGRAM                    648
unix  3      [ ]         DGRAM                    647

Any thoughts or pointers?


回答1:


I also had the same issue. Tried all the options suggested in this thread. But didnt help. Then just did ran:

ps -awwef | grep tomcat

and found some stale process running. I killed it using (-15 instead of -9)

sudo kill -15 <tomcat pid from previous command>

And woot! it worked. Restarted tomcat without any issue.




回答2:


NEVER kill a process with signal -9, because this type of killing process leaves its resources present in the system, which can only be removed after a server reboot. only use kill -9 only in extreme emergency. better to use kill -15, as it might take some time to cleanup resources, but you would always get proper flushing of that whole set of resources, that the process is consuming. so most probably, the tomcat is not working as it has left some of the resources left in the memory. So, either perform a reboot or try to find following:

  • through lsof command and grep it with tomcat. it will show you anything that has tomcat associated with it

lsof | grep tomcat

  • search of any pid lock file on filesystem, left by tomcat.
  • Also try to issue:

lsof -i TCP | grep 8080




回答3:


The port number is configured in $TOMCAT_HOME/conf/server.xml

If port 8080 is in use, change it in the server.xml file. Mine looks like this in server.xml

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



回答4:


Just running a lsof may be not enough. I suggest this command:

sudo lsof -i :8080

And then you can kill whatever process is holding the port (most probably another instance of tomcat).




回答5:


Just for the record: I got this error (as a newbie) because I started Apache before starting Tomcat.

If I stopped Apache, then started Tomcat and then started Apache, the errors disappeared.




回答6:


After entering the netstat -aon find the PID for 8080 port. Then go to task manager and find the Image Name for the PID in processes tab. right click on the Image Name and click on end process. Now if you start the server it will work.




回答7:


I have also ran into this problem, but in my case, I have updated my application in my server from application in my local source. I have searched running tomcat instances with different methods like shown above and killed all of them followed by running it several times, but no use.

The reason why tomcat not properly shutting down or starting up was JDK version of the application source: I have built it with JDK 1.8, but in my server there was 1.7. After rebuilding my application with JDK 1.7 I had it working in both local and server machines. Hope, this information also helps someone like me.




回答8:


Sometimes servlets must do a substantial amount of work to shut down, and as a result, tomcat may take some time to shutdown as well. If you wait a short bit before restarting the server, you may see the problem go away. If not, then it is possible a web application may not be responding to termination signals from the JVM, in which case tomcat may not correctly shut down.

Long story short, try adding a sleep to your restart script, or simply wait a short bit before calling start again.




回答9:


The problem is tomcat may not properly shut down. try adding a sleep to your restart script, or simply wait a short mint before start tomcat again.




回答10:


ps -awwef | grep tomcat

worked for me

found some stale process running. I killed it using (-15 instead of -9)




回答11:


The best solution is stop running tomcat instance using the following command:

kill $(ps -aef | grep java | grep apache-tomcat-7.0.47 | awk '{print $2}')

Change 7.0.47 with your tomcat version. It works fine and the port number, i.e., 8080, will be released soon.




回答12:


I was facing similar issue and found that 8080 port was being used for some other application . use netstat commnad on windows and see all the ports in use.

change the connector port in server.xml file . you can find this file in your tomcat installation directory under conf folder. open this file ,mine looked as below:

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

change the port value to some other port preferably in the 80 series. hope it works.



来源:https://stackoverflow.com/questions/8040640/tomcat-startup-8080-address-already-in-use

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!