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

前端 未结 1 1436
清歌不尽
清歌不尽 2021-01-22 00:28

i want to have a servlet to process inputs from a standalone java program. how to deploy this servlet in jboss. I put the servlet.class file in WEB-INF/classes and in web.xml i

相关标签:
1条回答
  • 2021-01-22 00:45

    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.

    0 讨论(0)
提交回复
热议问题