java.lang.NoSuchMethodError: javax.servlet.ServletContext.getEffectiveSessionTrackingModes()

來源:互聯網
上載者:User

最近在把jboss從4.2.2升級到6.0.0時候,遇到各種各樣的問題,主要都是類版本衝突,好容易把問題都找出來伺服器run起來之前,第一次訪問拋出了這個異常

An exception or error occurred in the container during the request processing: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getEffectiveSessionTrackingModes()Ljava/util/Set;
        at org.apache.catalina.connector.CoyoteAdapter.postParseRequest(CoyoteAdapter.java:567)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:359)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951)
        at java.lang.Thread.run(Thread.java:679) [:1.6.0_22]

搜了一下,下面這篇文章講得比較仔細,果斷分享之

http://stackoverflow.com/questions/8969497/java-lang-nosuchmethoderror-javax-servlet-servletcontext-geteffectivesessiont

貼出內容:

java.lang.NoSuchMethodError: javax.servlet.ServletContext.getEffectiveSessionTrackingModes()Ljava/util/Set;

This method is introduced in
Servlet 3.0. This error can have at least the following causes:

  1. Your web.xml is
    not declared conform at least Servlet 3.0.

  2. Your servlet container does not support at least Servlet 3.0.

  3. You have servlet container specific libraries of an older version in /WEB-INF/lib.

To solve this problem,

  1. Ensure that your web.xml root
    declaration conforms Servlet 3.0:

    <?xml version="1.0" encoding="UTF-8"?><web-app     xmlns="http://java.sun.com/xml/ns/javaee"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"    version="3.0">    <!-- Config here. --></web-app>
  2. Ensure that you're deploying to a Servlet 3.0 compatible container. In case of JBoss AS that would be at least version 6.0.0.

  3. Ensure that you don't have those libraries in /WEB-INF/lib.
    They do not belong there. This is a common beginner's mistake to "solve" compilation errors they faced in their IDE. See also How
    do I import the javax.servlet API in my Eclipse project?

You've declared your web.xml conform
Servlet 2.2. This is definitely wrong. Fix it accordingly.

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.