Reputation:
I use jetty 9.4.8.v20171121 with Java 9 and this is list of jetty modules I load:
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
This is the code I start 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();
And this is what I get:
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 [email protected]/org.eclipse.jetty.util.Loader.loadClass(Loader.java:65)
at [email protected]/org.eclipse.jetty.webapp.WebAppContext.loadConfigurations(WebAppContext.java:1035)
at [email protected]/org.eclipse.jetty.webapp.WebAppContext.preConfigure(WebAppContext.java:473)
at [email protected]/org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:544)
at [email protected]/org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at [email protected]/org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133)
at [email protected]/org.eclipse.jetty.server.Server.start(Server.java:418)
at [email protected]/org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:107)
at [email protected]/org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
at [email protected]/org.eclipse.jetty.server.Server.doStart(Server.java:385)
at [email protected]/org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
How to fix it?
Upvotes: 3
Views: 1193
Reputation: 49515
The Jars for Jetty 9.x (regardless of sub-version) are not JPMS modules.
In order for Jetty to properly support JPMS, it would require a radical change in the packaging and will definitely impact major parts of the Jetty codebase.
Note: If you have a desire to see Jetty be fully JPMS compliant, please comment on issue https://github.com/eclipse/jetty.project/issues/2189
Some things left to resolve before the JPMS effort in Jetty can proceed in earnest.
As for when Jetty will support JPMS, that's unlikely to ever occur with Jetty 9.x, it was briefly discussed for Jetty 10.x but it was determined that supporting Servlet 4.0, javax.websocket 1.1, and Java 8 were still important.
Once Java 8 is fully end of life, the process of migrating existing stable branches to JPMS are valid. (if that will happen is a different question).
We are keeping an eye on the open questions we have with the spec groups, and also targeting the Java 11 (LTS) release as a good candidate for JPMS support. That is likely to coincide with a (currently theoretical) Jetty 11.x as well.
Upvotes: 2