Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ClassNotFoundException: javax.servlet.AsyncContext in Jetty hello world in eclipse

Tags:

java

jetty

I have followed the link http://wiki.eclipse.org/Jetty/Tutorial/Jetty_HelloWorld tutorial (with Eclipse). and also looked at the existing stackoverflow here

I am using the aggregate jetty 8.0.0.jar and 8.1.3.jar along with the servlet-api-2.5.jar. I have added these 2 jars to the class path and also included the slf4j-simple-1.6.4.jar too.

I am still getting

`
2012-05-23 15:23:06.813:WARN: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)

`

Any thoughts ?

like image 200
bhavs Avatar asked May 23 '12 07:05

bhavs


1 Answers

I think you need the servlet api 3, not 2.5. AsyncContext was introduced in Servlet 3.0, it doesn't exist in 2.5.

like image 161
Kai Sternad Avatar answered Nov 08 '22 04:11

Kai Sternad