安装jetty后,使用下面的命名启动jetty:
java -jar start.jar
在启动jetty时,程序一致在报错,其中错误日志如下所示:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.jetty.start.Main.invokeMain(Main.java:215)
at org.eclipse.jetty.start.Main.start(Main.java:456)
at org.eclipse.jetty.start.Main.main(Main.java:76)
Caused by: java.net.BindException: Address already in use
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:433)
at sun.nio.ch.Net.bind(Net.java:425)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:351)
at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:319)
at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:235)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.server.Server.doStart(Server.java:406)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1540)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1462)
... 7 more
Usage: java -jar start.jar [options] [properties] [configs]
java -jar start.jar --help # for more information
其中问题的原因在:
Caused by: java.net.BindException: Address already in use
在浏览器中输入:localhost:8080一直不能显示jetty的初始界面。
原因分析:考虑到之前配置过Tomcat,端口号8080已经被占用。将Tomcat的服务停止后,仍旧是不能显示jetty的初始界面,也就是jetty服务仍旧不能启动。当然还有一个原因需要考虑:maven控制台,将maven的控制台关闭后在启动jetty服务。问题就解决了。
解决方案:关闭Tomcat的服务,关闭maven控制台,启动jetty服务。
jetty启动后显示: