Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
148 views
in Technique[技术] by (71.8m points)

java - ClassNotFoundException: org.eclipse.jetty.util.component.AbstractLifeCycle running inside jetty

I am having an issue running a servlet in jetty on Ubuntu 13.04. The server is installed using apt-get and started using sudo service jetty start. The app requires the class org.eclipse.jetty.util.component.AbstractLifeCycle but I get a class not found error. Here is the stack trace:

java.lang.NoClassDefFoundError: org/eclipse/jetty/util/component/AbstractLifeCycle
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:788)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:447)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:420)
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:382)
at org.cometd.server.CometdServlet.newBayeuxServer(CometdServlet.java:130)
at org.cometd.server.CometdServlet.init(CometdServlet.java:64)
at org.cometd.annotation.AnnotationCometdServlet.init(AnnotationCometdServlet.java:54)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:542)
at org.eclipse.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:424)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:671)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:505)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:138)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:564)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:213)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1094)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:432)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:175)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1028)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:136)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:258)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:445)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:267)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:224)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.run(AbstractConnection.java:358)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:601)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:532)
at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.ClassNotFoundException:          org.eclipse.jetty.util.component.AbstractLifeCycle
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:420)
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:382)
... 37 more
Caused by:

java.lang.ClassNotFoundException: org.eclipse.jetty.util.component.AbstractLifeCycle
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:420)
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:382)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:788)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:447)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:420)
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:382)
at org.cometd.server.CometdServlet.newBayeuxServer(CometdServlet.java:130)
at org.cometd.server.CometdServlet.init(CometdServlet.java:64)
at org.cometd.annotation.AnnotationCometdServlet.init(AnnotationCometdServlet.java:54)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:542)
at org.eclipse.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:424)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:671)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:505)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:138)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:564)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:213)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1094)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:432)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:175)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1028)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:136)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:258)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:445)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:267)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:224)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.run(AbstractConnection.java:358)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:601)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:532)
at java.lang.Thread.run(Thread.java:724)

So far I have:

1) Examined the command used to start jetty to find the classpath using ps:

/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java -Djetty.home=/opt/jetty -Dovc.db_config=/home/ubuntu/ovc/data/ovc-repo/config/sql.properties -Dovc.repo_loc=/home/ubuntu/ovc/data/ovc-repo -cp /opt/jetty/lib/jetty-xml-9.0.4.v20130625.jar:/opt/jetty/lib/servlet-api-3.0.jar:/opt/jetty/lib/jetty-http-9.0.4.v20130625.jar:/opt/jetty/lib/jetty-continuation-9.0.4.v20130625.jar:/opt/jetty/lib/jetty-server-9.0.4.v20130625.jar:/opt/jetty/lib/jetty-security-9.0.4.v20130625.jar:/opt/jetty/lib/jetty-servlet-9.0.4.v20130625.jar:/opt/jetty/lib/jetty-webapp-9.0.4.v20130625.jar:/opt/jetty/lib/jetty-deploy-9.0.4.v20130625.jar:/opt/jetty/lib/jetty-jmx-9.0.4.v20130625.jar:/opt/jetty/lib/jsp/com.sun.el-2.2.0.v201303151357.jar:/opt/jetty/lib/jsp/javax.el-2.2.0.v201303151357.jar:/opt/jetty/lib/jsp/javax.servlet.jsp.jstl-1.2.0.v201105211821.jar:/opt/jetty/lib/jsp/javax.servlet.jsp-2.2.0.v201112011158.jar:/opt/jetty/lib/jsp/org.apache.jasper.glassfish-2.2.2.v201112011158.jar:/opt/jetty/lib/jsp/org.apache.taglibs.standard.glassfish-1.2.0.v201112081803.jar:/opt/jetty/lib/jsp/org.eclipse.jdt.core-3.8.2.v20130121.jar:/opt/jetty/resources:/opt/jetty/lib/websocket/websocket-api-9.0.4.v20130625.jar:/opt/jetty/lib/websocket/websocket-client-9.0.4.v20130625.jar:/opt/jetty/lib/websocket/websocket-common-9.0.4.v20130625.jar:/opt/jetty/lib/websocket/websocket-server-9.0.4.v20130625.jar:/opt/jetty/lib/websocket/websocket-servlet-9.0.4.v20130625.jar:/opt/jetty/lib/jetty-util-9.0.4.v20130625.jar:/opt/jetty/lib/jetty-io-9.0.4.v20130625.jar org.eclipse.jetty.xml.XmlConfiguration /tmp/start2620351902332669076.properties /opt/jetty/etc/jetty.xml /opt/jetty/etc/jetty-jmx.xml /opt/jetty/etc/jetty-http.xml /opt/jetty/etc/jetty-deploy.xml /opt/jetty/etc/jetty-logging.xml /opt/jetty/etc/jetty-started.xml

2) Inspected the jar that should contain the missing class:

~$ jar -tf /opt/jetty/lib/jetty-util-9.0.4.v20130625.jar | grep AbstractLife
org/eclipse/jetty/util/component/AbstractLifeCycle$AbstractLifeCycleListener.class
org/eclipse/jetty/util/component/AbstractLifeCycle.class

Can anyone give a suggestion as to what to check next, I am out of ideas? Thank you.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Put the jetty-util-9.0.4.v20130625.jar in your webapp's WEB-INF/lib/

As you can see from the stacktrace, you are attempting to use a class found in jetty-util, from within a webapp.

at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:420)

This tells you that the webapp needs the class from jetty-util.

Because of webapp classloader isolation, and various rules within Jetty, the classes for org.eclipse.jetty.util.* are not provided by the server, and must be provided by the webapp's own WEB-INF/lib directory.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...