ClassNotFoundException:eclipse中Jetty hello world中的javax.servlet.AsyncContext

时间:2012-05-23 07:31:21

标签: java jetty

我已经关注了链接http://wiki.eclipse.org/Jetty/Tutorial/Jetty_HelloWorld教程(使用Eclipse)。并查看了现有的stackoverflow here

我使用聚合jetty 8.0.0.jar和8.1.3.jar以及servlet-api-2.5.jar。我已将这两个jar添加到类路径中,并且还包括slf4j-simple-1.6.4.jar。

我还在

`
    2012-05-23 15:23:06.813:警告:oeji.nio:     java.lang.NoClassDefFoundError:javax / servlet / AsyncContext

at org.eclipse.jetty.server.HttpConnection.<init>(HttpConnection.java:155)
at org.eclipse.jetty.server.AsyncHttpConnection.<init>(AsyncHttpConnection.java:19)
at org.eclipse.jetty.server.nio.SelectChannelConnector$SelectChannelHttpConnection.<init>(SelectChannelConnector.java:309)
at org.eclipse.jetty.server.nio.SelectChannelConnector$SelectChannelHttpConnection.<init>(SelectChannelConnector.java:303)
at org.eclipse.jetty.server.nio.SelectChannelConnector.newConnection(SelectChannelConnector.java:286)
at org.eclipse.jetty.server.nio.SelectChannelConnector$ConnectorSelectorManager.newConnection(SelectChannelConnector.java:364)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.<init>(SelectChannelEndPoint.java:71)
at org.eclipse.jetty.server.nio.SelectChannelConnector.newEndPoint(SelectChannelConnector.java:274)
at org.eclipse.jetty.server.nio.SelectChannelConnector$ConnectorSelectorManager.newEndPoint(SelectChannelConnector.java:370)
at org.eclipse.jetty.io.nio.SelectorManager$SelectSet.createEndPoint(SelectorManager.java:938)
at org.eclipse.jetty.io.nio.SelectorManager$SelectSet.doSelect(SelectorManager.java:497)
at org.eclipse.jetty.io.nio.SelectorManager$1.run(SelectorManager.java:283)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)
at java.lang.Thread.run(Thread.java:679)

   Caused by: 
    java.lang.ClassNotFoundException: javax.servlet.AsyncContext
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at org.eclipse.jetty.server.HttpConnection.<init>(HttpConnection.java:155)
at org.eclipse.jetty.server.AsyncHttpConnection.<init>(AsyncHttpConnection.java:19)
at org.eclipse.jetty.server.nio.SelectChannelConnector$SelectChannelHttpConnection.<init>(SelectChannelConnector.java:309)
at org.eclipse.jetty.server.nio.SelectChannelConnector$SelectChannelHttpConnection.<init>(SelectChannelConnector.java:303)
at org.eclipse.jetty.server.nio.SelectChannelConnector.newConnection(SelectChannelConnector.java:286)
at org.eclipse.jetty.server.nio.SelectChannelConnector$ConnectorSelectorManager.newConnection(SelectChannelConnector.java:364)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.<init>(SelectChannelEndPoint.java:71)
at org.eclipse.jetty.server.nio.SelectChannelConnector.newEndPoint(SelectChannelConnector.java:274)
at org.eclipse.jetty.server.nio.SelectChannelConnector$ConnectorSelectorManager.newEndPoint(SelectChannelConnector.java:370)
at org.eclipse.jetty.io.nio.SelectorManager$SelectSet.createEndPoint(SelectorManager.java:938)
at org.eclipse.jetty.io.nio.SelectorManager$SelectSet.doSelect(SelectorManager.java:497)
at org.eclipse.jetty.io.nio.SelectorManager$1.run(SelectorManager.java:283)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)
at java.lang.Thread.run(Thread.java:679)

`

有什么想法?

1 个答案:

答案 0 :(得分:18)

我认为你需要servlet api 3,而不是2.5。 AsyncContext是在Servlet 3.0中引入的,它在2.5中不存在。