ClassNotFoundException: javax.servlet.AsyncContext in Jetty hello world

后端 未结 2 1442
陌清茗
陌清茗 2020-12-10 15:32

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 ser

2条回答
  •  借酒劲吻你
    2020-12-10 15:55

    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:

    • What exactly is Java EE?
    • How do I import the javax.servlet API in my Eclipse project?

提交回复
热议问题