I am trying to follow the http://wiki.eclipse.org/Jetty/Tutorial/Jetty_HelloWorld tutorial (with Eclipse). The project compiles fine. However, when I hit the localhost server I get:
java.lang.ClassNotFoundException: javax.servlet.AsyncContext
Now it looks like that is defined in Java EE what do I need to add to the build path to get this to work? I have installed Java EE but I am not sure where to go from there.
I am trying this with
jetty-all-8.0.4.v20111024.jar
servlet-api-2.5.jar
That class is introduced in Servlet 3.0 which is part of Java EE 6. Jetty 7 as mentioned in that tutorial is a Servlet 2.5 container. Servlet 2.5 is part of Java EE 5. You need to upgrade to Jetty 8 which is a Servlet 3.0 container.
Downloading and installing the whole Java EE pack as available here makes no sense as that basically gives you the Java EE reference implementation Glassfish back, not Jetty, while you need a newer version of Jetty, not Glassfish.
You also need to make sure that you don't have downloaded an arbitrary servlet-api.jar
file from somewhere and placed it in the classpath while you already have a fullworthy servlet container like Jetty at your hands (which is a classic beginner's mistake to circumvent compilation errors they faced on the javax.servlet
API).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With