ClassNotFoundException:Jetty hello world中的javax.servlet.AsyncContext [英] ClassNotFoundException: javax.servlet.AsyncContext in Jetty hello world
问题描述
我正在尝试关注 http://wiki.eclipse.org/Jetty/Tutorial/Jetty_HelloWorld 教程(使用Eclipse)。该项目编写得很好。但是,当我点击localhost服务器时,我得到:
java.lang.ClassNotFoundException:javax.servlet.AsyncContext
现在它看起来像是在 Java EE 我需要添加到构建路径以使其工作吗?我已经安装了Java EE,但我不确定从那里开始。
我正在尝试这个
jetty-all-8.0.4.v20111024.jar
servlet-api-2.5.jar
该类是介绍在Servlet 3.0中,它是Java EE 6的一部分。该教程中提到的Jetty 7是一个Servlet 2.5容器。 Servlet 2.5是Java EE 5的一部分。您需要升级到Jetty 8,这是一个Servlet 3.0容器。
下载并安装整个Java EE包这里没有任何意义,因为它基本上为您提供了Java EE参考实现Glassfish,而不是Jetty,而您需要更新版本的Jetty,而不是Glassfish。
您还需要确保没有从某个地方下载任意 servlet-api.jar
文件并将其放入类路径,而你已经拥有一个像Jetty这样的值得满足的servlet容器(这是一个经典的初学者错误,以避免他们在 javax.servlet
API上遇到的编译错误。) / p>
另请参阅:
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).
See also:
这篇关于ClassNotFoundException:Jetty hello world中的javax.servlet.AsyncContext的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!