Tomcat启动,8080地址已经在使用中

时间:2011-11-07 18:06:24

标签: tomcat amazon-ec2 lifecycleexception

设置为:

  • Amazon EC2
  • Tomcat(安全转发至8443)
  • Apache 2.2

我运行shutdown.sh,没有错误。

但是当我试图破坏startup.sh时,我收到了这个错误:

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

我尝试了netstat -aon | grep 8080之类的命令我尝试了ps -efl | grep java并使用kill <pid> 9 pkill java杀了该过程等等......

这就是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

有任何想法或指示吗?

13 个答案:

答案 0 :(得分:24)

我也有同样的问题。尝试了这个主题中建议的所有选项。但没有帮助。然后就跑了:

ps -awwef | grep tomcat

发现一些过时的流程正在运行。我用(-15而不是-9)杀了它

sudo kill -15 <tomcat pid from previous command>

哇!有效。重启tomcat没有任何问题。

答案 1 :(得分:15)

永远不要使用信号-9杀死进程,因为这种类型的终止进程会使其资源出现在系统中,只能在服务器重启后删除。仅在极端紧急情况下才使用kill -9。最好使用kill -15,因为它可能需要一些时间来清理资源,但是你总是可以正确地刷新整个资源集,这个过程正在消耗。所以最有可能的是,tomcat没有工作,因为它留下了内存中留下的一些资源。因此,要么执行重新启动,要么尝试查找以下内容:

  • 通过lsof命令并使用tomcat grep它。它会向你展示任何与它相关的tomcat
  

lsof | grep tomcat

  • 搜索文件系统上的任何pid锁文件,由tomcat保留。
  • 还尝试发出:
  

lsof -i TCP | grep 8080

答案 2 :(得分:9)

端口号在$ TOMCAT_HOME / conf / server.xml

中配置

如果正在使用端口8080,请在server.xml文件中进行更改。我在server.xml中看起来像这样

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

答案 3 :(得分:9)

仅仅运行lsof可能还不够。我建议这个命令:

sudo lsof -i :8080

然后你可以杀死持有端口的任何进程(很可能是另一个tomcat实例)。

答案 4 :(得分:4)

仅供记录:我收到此错误(作为新手)因为我在启动Tomcat之前启动了Apache。

如果我停止Apache,然后启动Tomcat然后启动Apache,则错误消失。

答案 5 :(得分:2)

进入netstat后 - 找到8080端口的PID。然后转到任务管理器并在进程选项卡中找到PID的映像名称。右键单击图像名称,然后单击结束进程。现在,如果您启动服务器,它将起作用。

答案 6 :(得分:2)

我也遇到过这个问题,但在我的情况下,我已经从我本地源中的应用程序更新了我的服务器中的应用程序。我已经使用上面显示的不同方法搜索运行tomcat实例并杀死所有这些实例,然后运行它几次,但没有用。

tomcat没有正确关闭或启动的原因是JDK版本的应用程序源:我用JDK 1.8构建它,但在我的服务器中有1.7。使用JDK 1.7重建我的应用程序后,我让它在本地和服务器机器上工作。希望,这些信息也可以帮助像我这样的人。

答案 7 :(得分:1)

有时servlet必须做大量工作才能关闭,因此tomcat也可能需要一些时间才能关闭。如果在重新启动服务器之前等待一小段,您可能会看到问题消失。如果没有,则Web应用程序可能无法响应来自JVM的终止信号,在这种情况下,tomcat可能无法正确关闭。

长话短说,尝试在重启脚本中添加一个睡眠,或者只是等一会儿再重新开始调用。

答案 8 :(得分:1)

问题是tomcat可能无法正常关闭。尝试在重启脚本中添加一个睡眠,或者在再次启动tomcat之前等待一小段时间。

答案 9 :(得分:0)

ps -awwef | grep tomcat

为我工作

发现一些过时的流程正在运行。我用(-15而不是-9)杀了它

答案 10 :(得分:0)

最佳解决方案是使用以下命令停止运行tomcat实例:

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

使用您的tomcat版本更改7.0.47。它工作正常,端口号,即8080,将很快发布。

答案 11 :(得分:0)

我遇到了类似的问题,发现8080端口被用于其他一些应用程序。在Windows上使用 netstat commnad并查看正在使用的所有端口。

更改server.xml文件中的连接器端口。您可以在 conf 文件夹下的tomcat安装目录中找到此文件。打开这个文件,我看起来如下:

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

将端口值更改为80系列中的其他端口。希望它有效。

答案 12 :(得分:0)

我遇到了同样的问题,几个小时后我尝试了上述所有解决方案,发现没有使用端口的进程,也没有正在运行的tomcat实例,并且一台干净的机器也显示了此问题。

但是随后我发现server.xml具有相同端口的重复“ Connector”条目。删除该问题可以解决我的问题。