我在Java 9中使用了jetty 9.4.8.v20171121,这是我加载的jetty模块列表:
jetty-server-9.4.8.v20171121.jar
jetty-servlet-9.4.8.v20171121.jar
jetty-servlets-9.4.8.v20171121.jar
jetty-util-9.4.8.v20171121.jar
jetty-xml-9.4.8.v20171121.jar
jetty-http-9.4.8.v20171121.jar
jetty-io-9.4.8.v20171121.jar
jetty-security-9.4.8.v20171121.jar
jetty-webapp-9.4.8.v20171121.jar这是我启动Jetty的代码:
Server server = new Server( 8080 );
WebAppContext webapp = new WebAppContext();
webapp.setContextPath( "/" );
File warFile = new File(
"/home/Sam/WebServer/jar/org.test.site.fend-0.1.0-SNAPSHOT.war" );
if (!warFile.exists())
{
throw new RuntimeException( "Unable to find WAR File: "
+ warFile.getAbsolutePath() );
}
webapp.setWar( warFile.getAbsolutePath() );
webapp.setExtractWAR(true);
webapp.setAttribute(
"org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
".*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/[^/]*taglibs.*\\.jar$" );
server.setHandler( webapp );
server.start();
server.dumpStdErr();我得到的是:
2018-02-06 17:18:03:111 [main] DEBUG org.eclipse.jetty.util.component.AbstractLifeCycle - starting o.e.j.w.WebAppContext@659499f1{/,null,UNAVAILABLE}{/home/Sam/WebServer/jar/org.test.site.fend-0.1.0-SNAPSHOT.war}
2018-02-06 17:18:03:115 [main] WARN org.eclipse.jetty.webapp.WebAppContext - Failed startup of context o.e.j.w.WebAppContext@659499f1{/,null,UNAVAILABLE}{/home/Sam/WebServer/jar/org.test.site.fend-0.1.0-SNAPSHOT.war}
java.lang.ClassNotFoundException: org.eclipse.jetty.webapp.WebInfConfiguration
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
at jetty.util@9.4.8.v20171121/org.eclipse.jetty.util.Loader.loadClass(Loader.java:65)
at jetty.webapp@9.4.8.v20171121/org.eclipse.jetty.webapp.WebAppContext.loadConfigurations(WebAppContext.java:1035)
at jetty.webapp@9.4.8.v20171121/org.eclipse.jetty.webapp.WebAppContext.preConfigure(WebAppContext.java:473)
at jetty.webapp@9.4.8.v20171121/org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:544)
at jetty.util@9.4.8.v20171121/org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at jetty.util@9.4.8.v20171121/org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133)
at jetty.server@9.4.8.v20171121/org.eclipse.jetty.server.Server.start(Server.java:418)
at jetty.util@9.4.8.v20171121/org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:107)
at jetty.server@9.4.8.v20171121/org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
at jetty.server@9.4.8.v20171121/org.eclipse.jetty.server.Server.doStart(Server.java:385)
at jetty.util@9.4.8.v20171121/org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)怎么修呢?
发布于 2018-02-08 18:22:22
Jetty9.x的Jars (不管子版本)不是JPMS模块。
为了使Jetty能够正确地支持JPMS,它需要对包装进行彻底的修改,并且肯定会影响Jetty代码库的主要部分。
注:如果您希望看到Jetty完全遵守JPMS,请对https://github.com/eclipse/jetty.project/issues/2189问题发表评论
在Jetty的JPMS努力之前,还需要解决一些问题。
至于Jetty何时支持JPMS,Jetty9.x不太可能出现这种情况,我们简要讨论了Jetty10.x,但确定支持Servlet4.0、javax.websocket 1.1和Java8仍然很重要。
一旦Java 8完全结束生命,将现有的稳定分支迁移到JPMS的过程是有效的。(如果会发生这种情况,则是另一个问题)。
我们正在关注我们与规范组之间的公开问题,并将Java 11 (LTS)版本作为JPMS支持的良好候选。这很可能与(目前理论上的)Jetty11.x相吻合。
https://stackoverflow.com/questions/48645614
复制相似问题