-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ClassNotFoundException when using Jetty 9.4.14 as Embedded Server #3219
Comments
I tried different versions of jetty. It does not work on jetty 9.4.10 either but works fine without any exception on jetty 9.3.8. |
@0Steve0 dude, you did not even provide a stack trace, nor the name of the class that was not found. |
@sbordet sorry mate, forgot to update my description. |
@0Steve0 what is your classpath? List at least Jetty's jars. |
You obviously have a strange environment. Your environment obviously loaded The only time I've seen this is when using OSGi and/or an IBM JVM. |
@joakime you are right, i am using OSGI |
I found a similar issue here: #705. |
@0Steve0 make sure you have and use Apache SpiFly with your OSGi environment. (it's a requirement for ServiceLoader functionality) |
@0Steve0 also, you'll have nearly no luck using standard techniques and behaviors with OSGi. The entire See: https://github.com/eclipse/jetty.project/tree/jetty-9.4.x/jetty-osgi Probably need to start at In short, you'll have a tremendous amount of boilerplate code to "setup" of the OSGi environment, along with special one-off classes of existing Jetty classes you'll need to use just because of your choice of OSGi. |
Since BouncyCastle version 1.69, you also need to copy the bcutil-<version>.jar to lib/ext. |
@0Steve0 OSGi classloading is completely different from standard jvm classloading. That is why we provide a bunch of helper osgi bundles to make webapp classloading work in this environment which are discussed here: https://www.eclipse.org/jetty/documentation/jetty-9/index.html#framework-jetty-osgi. Explicltly setting the context classloader as the classloader that loaded some particular class may happen solve some of your classloading issues but is not a generic solution with OSGi. I strongly encourage you to deploy the the jetty-osgi-boot (and jetty-osgi-boot-jsp jars if you are using jsps). |
I am using jetty as a embedded Server in eclipse. It keep throwing ClassNotFoundException when start the server.
Stack track looks like:
Failed startup of context o.e.j.w.WebAppContext@6561e97d{/,null,UNAVAILABLE}
java.lang.ClassNotFoundException: org.eclipse.jetty.webapp.WebInfConfiguration
at java.net.URLClassLoader.findClass(URLClassLoader.java:609)
at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:925)
at java.lang.ClassLoader.loadClass(ClassLoader.java:870)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:343)
at java.lang.ClassLoader.loadClass(ClassLoader.java:853)
at org.eclipse.osgi.internal.framework.ContextFinder.loadClass(ContextFinder.java:132)
at java.lang.ClassLoader.loadClass(ClassLoader.java:853)
at org.eclipse.jetty.util.Loader.loadClass(Loader.java:65)
at org.eclipse.jetty.webapp.WebAppContext.loadConfigurations(WebAppContext.java:1035)
at org.eclipse.jetty.webapp.WebAppContext.preConfigure(WebAppContext.java:473)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:544)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
at org.eclipse.jetty.server.Server.start(Server.java:419)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
at org.eclipse.jetty.server.Server.doStart(Server.java:386)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
My code is quite simple:
Server server = new Server(8080)
WebAppContext context = new WebAppContext();
..........
context.addServlet(xxxx);
............
server.start();
The text was updated successfully, but these errors were encountered: