问题
I started a few months ago to maintain an old Spring project using the Jetty Maven plugin. I'm currently trying to port it to Java 11 but Jetty won't start the server and (silently) fails with MultiException[java.lang.NoClassDefFoundError: org/eclipse/jetty/util/FutureCallback, java.lang.NoClassDefFoundError: org/eclipse/jetty/util/LazyList]
.
This seems to be an old bug of the Jetty Maven plugin that I can reproduce on various 9.x
versions.
It seems fixed in versions 10 and 11 and I would gladly use these versions but both are still in alpha, configuration has radically changed and documentation is not published yet.
maven.compiler.source
and maven.compiler.target
are both set to 11 in POM and nothing changes if I put dependencies providing org.eclipse.jetty.util.FutureCallback
and org.eclipse.jetty.util.LazyList
in the POM.
[WARNING] FAILED ServletHandler@4ba402b5{FAILED}: java.lang.NoClassDefFoundError: org/eclipse/jetty/util/LazyList
java.lang.NoClassDefFoundError: org/eclipse/jetty/util/LazyList
at org.eclipse.jetty.servlet.ServletHandler.doStop (ServletHandler.java:277)
at org.eclipse.jetty.util.component.AbstractLifeCycle.stop (AbstractLifeCycle.java:93)
at org.eclipse.jetty.util.component.ContainerLifeCycle.stop (ContainerLifeCycle.java:180)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop (ContainerLifeCycle.java:201)
at org.eclipse.jetty.server.handler.AbstractHandler.doStop (AbstractHandler.java:108)
at org.eclipse.jetty.security.SecurityHandler.doStop (SecurityHandler.java:437)
at org.eclipse.jetty.security.ConstraintSecurityHandler.doStop (ConstraintSecurityHandler.java:425)
at org.eclipse.jetty.util.component.AbstractLifeCycle.stop (AbstractLifeCycle.java:93)
at org.eclipse.jetty.util.component.ContainerLifeCycle.stop (ContainerLifeCycle.java:180)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop (ContainerLifeCycle.java:201)
at org.eclipse.jetty.server.handler.AbstractHandler.doStop (AbstractHandler.java:108)
at org.eclipse.jetty.server.session.SessionHandler.doStop (SessionHandler.java:519)
at org.eclipse.jetty.util.component.AbstractLifeCycle.stop (AbstractLifeCycle.java:93)
at org.eclipse.jetty.util.component.ContainerLifeCycle.stop (ContainerLifeCycle.java:180)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop (ContainerLifeCycle.java:201)
at org.eclipse.jetty.server.handler.AbstractHandler.doStop (AbstractHandler.java:108)
at org.eclipse.jetty.server.handler.ContextHandler.stopContext (ContextHandler.java:1061)
at org.eclipse.jetty.servlet.ServletContextHandler.stopContext (ServletContextHandler.java:375)
at org.eclipse.jetty.webapp.WebAppContext.stopWebapp (WebAppContext.java:1462)
at org.eclipse.jetty.maven.plugin.JettyWebAppContext.stopWebapp (JettyWebAppContext.java:342)
at org.eclipse.jetty.webapp.WebAppContext.stopContext (WebAppContext.java:1428)
at org.eclipse.jetty.server.handler.ContextHandler.doStop (ContextHandler.java:1115)
at org.eclipse.jetty.servlet.ServletContextHandler.doStop (ServletContextHandler.java:286)
at org.eclipse.jetty.webapp.WebAppContext.doStop (WebAppContext.java:547)
at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStop (JettyWebAppContext.java:433)
回答1:
This is a interesting side-effect of interaction between maven and jetty.
What happens is that on jetty stop/shutdown the maven process yanks the classloader out from underneath the jetty threads leaving random errors in its wake, some even being unable to find classes that they need to perform a clean shutdown.
See https://github.com/eclipse/jetty.project/issues/4410
There is no workaround or fix for this that either Jetty or Maven has found.
If you find a solution please comment on the above issue (or file a new issue), and we'll document it.
来源:https://stackoverflow.com/questions/64247100/getting-noclassdeffounderror-for-classes-futurecallback-and-lazylist-using