我有一个正在通过Jetty运行的Java战争。 多年来,它一直在多台Windows 7计算机上工作。 但是现在Windows 7计算机上的新安装产生了错误,我不明白这些错误。 我在日志之下发帖直到错误的地步:
C:\Users\QT\Desktop\vcctl\scripts>cd ..\src C:\Users\QT\Desktop\vcctl\src>java -classpath "lib/derby.jar:lib/derbytools.jar" -Dorg.eclipse.jetty.server.Request.maxFormKeys=20000 -jar "VcctlWrapper.jar" 2016-03-21 15:42:11.866:INFO::AWT-EventQueue-0: Logging initialized @204ms Current relative path is: C:\Users\QT\Desktop\vcctl\src 2016-03-21 15:42:11.969:INFO:oejs.Server:AWT-EventQueue-0: jetty-9.1.3.v20140225 Mar 21, 2016 3:42:13 PM org.apache.struts.action.ActionServlet initChain INFO: Loading chain catalog from jar:file:/C:/Users/QT/AppData/Local/Temp/jetty-0.0.0.0-8080-vcctl.war-_vcctl-any-7374762875405590280.dir/webapp/WEB-INF/lib/struts-tiles-1.3.8.jar!/org/apache/struts/tiles/chain-config.xml Mar 21, 2016 3:42:13 PM org.apache.struts.action.ActionServlet initChain INFO: Loading chain catalog from jar:file:/C:/Users/QT/Desktop/vcctl/src/lib/struts-tiles-1.3.8.jar!/org/apache/struts/tiles/chain-config.xml Mar 21, 2016 3:42:13 PM org.apache.struts.config.impl.ModuleConfigImpl addAction Config WARNING: Overriding ActionConfig of path /my-files/viewImage Mar 21, 2016 3:42:13 PM org.apache.struts.tiles.TilesPlugin initDefinitionsFactory INFO: Tiles definition factory loaded for module ''. 2016-03-21 15:42:13.626:INFO:oejsh.ContextHandler:AWT-EventQueue-0: Started oejwWebAppContext@3c6dee0f{/vcctl,file:/C:/Users/QT/AppData/Local/Temp/jetty-0.0.0.0-8080-vcctl.war-_vcctl-any-7374762875405590280.dir/webapp/,AVAILABLE}{C:\Users\QT\Desktop\vcctl\src/vcctl.war} 2016-03-21 15:42:13.635:WARN:oejuc.AbstractLifeCycle:AWT-EventQueue-0: FAILED ServerConnector@3ba4f2fd{HTTP/1.1}{0.0.0.0:8080}: java.net.BindException: Address already in use: bind java.net.BindException: Address already in use: bind at sun.nio.ch.Net.bind0(Native Method) at sun.nio.ch.Net.bind(Unknown Source) at sun.nio.ch.Net.bind(Unknown Source) at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source) at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source) at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:279) at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80) at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:218) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.server.Server.doStart(Server.java:337) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at vcctl.webServiceRunner.startJettyServer(webServiceRunner.java:98) at vcctl.webServiceRunner.<init>(webServiceRunner.java:40) at vcctl.webServiceRunner$1.run(webServiceRunner.java:107) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$300(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) 2016-03-21 15:42:13.639:WARN:oejuc.AbstractLifeCycle:AWT-EventQueue-0: FAILED org.eclipse.jetty.server.Server@4a4cdea2: java.net.BindException: Address already in use: bind java.net.BindException: Address already in use: bind at sun.nio.ch.Net.bind0(Native Method) at sun.nio.ch.Net.bind(Unknown Source) at sun.nio.ch.Net.bind(Unknown Source) at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source) at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source) at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:279) at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80) at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:218) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.server.Server.doStart(Server.java:337) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at vcctl.webServiceRunner.startJettyServer(webServiceRunner.java:98) at vcctl.webServiceRunner.<init>(webServiceRunner.java:40) at vcctl.webServiceRunner$1.run(webServiceRunner.java:107) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$300(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)
在我的其他Windows 7计算机上,日志消息如下所示:
C:\Users\bullard\Desktop\vcctl\scripts>cd ..\src C:\Users\bullard\Desktop\vcctl\src>java -classpath "lib/derby.jar:lib/derbytools.jar" -Dorg.eclipse.jetty.server.Request.maxFormKeys=20000 -jar "VcctlWrapper.jar" 2016-03-21 17:34:04.520:INFO::AWT-EventQueue-0: Logging initialized @172ms Current relative path is: C:\Users\bullard\Desktop\vcctl\src 2016-03-21 17:34:04.598:INFO:oejs.Server:AWT-EventQueue-0: jetty-9.1.3.v20140225 Mar 21, 2016 5:34:05 PM org.apache.struts.action.ActionServlet initChain INFO: Loading chain catalog from jar:file:/C:/Users/bullard/AppData/Local/Temp/jetty-0.0.0.0-8080-vcctl.war-_vcctl-any-9120726856785823814.dir/webapp/WEB-INF/lib/struts-tiles-1.3.8.jar!/org/apache/struts/tiles/chain-config.xml Mar 21, 2016 5:34:05 PM org.apache.struts.action.ActionServlet initChain INFO: Loading chain catalog from jar:file:/C:/Users/bullard/Desktop/vcctl/src/lib/struts-tiles-1.3.8.jar!/org/apache/struts/tiles/chain-config.xml Mar 21, 2016 5:34:05 PM org.apache.struts.config.impl.ModuleConfigImpl addAction Config WARNING: Overriding ActionConfig of path /my-files/viewImage Mar 21, 2016 5:34:05 PM org.apache.struts.tiles.TilesPlugin initDefinitionsFactory INFO: Tiles definition factory loaded for module ''. 2016-03-21 17:34:05.955:INFO:oejsh.ContextHandler:AWT-EventQueue-0: Started oejwWebAppContext@1ac6103{/vcctl,file:/C:/Users/bullard/AppData/Local/Temp/jetty-0.0.0.0-8080-vcctl.war-_vcctl-any-9120726856785823814.dir/webapp/,AVAILABLE}{C: \Users\bullard\Desktop\vcctl\src/vcctl.war} 2016-03-21 17:34:05.971:INFO:oejs.ServerConnector:AWT-EventQueue-0: Started ServerConnector@146eb1b{HTTP/1.1}{0.0.0.0:8080} 2016-03-21 17:34:05.971:INFO:oejs.Server:AWT-EventQueue-0: Started @1623ms
当另一个Jetty实例或另一个进程在Jetty服务器试图运行的同一端口上运行时,会发生这种情况。 Jetty在默认端口8080上运行。因此,要么有另一个Jetty实例,要么是在该服务器上运行的Tomcat服务器占用端口8080(或任何您配置的端口)。
您可以修改jetty.xml
文件并通过更改以下行更新jetty.port
:
<Set name="port"><SystemProperty name="jetty.port" default="80"/></Set>
但在此之前,我会检查taskmgr
进程,如当前正在运行的jetty或tomcat。 您还可以检查netstat -a -b
是否正在运行进程以及它们正在使用的端口。