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

查看:105
本文介绍了java.lang.NoSuchMethodError:javax.servlet.ServletContext.getEffectiveSessionTrackingModes()Ljava / util / Set;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有一个servlet来处理来自独立java程序的输入。如何在jboss中部署这个servlet。我将servlet.class文件放在WEB-INF / classes中,在web.xml中我将servlet url映射为.do。从我的Java客户端程序,我打开使用URL对象连接到servlet。使用localhost:8080 / .do。但我得到以下错误:

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 gave the servlet url mapping as ".do". From my Java client program i opened connected to the servlet using a URL object. using localhost:8080/.do. BUT i am getting the folowing error:


  ERROR [org.apache.catalina.connector.CoyoteAdapter] 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)

web.xml文件内容:

web.xml file contents :

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "java.sun.com/j2ee/dtds/web-app_2_2.dtd">; 
<web-app> 
     <servlet>
         <servlet-name>ReverseServlet</servlet-name> 
         <servlet-class>ReverseServlet</servlet-class> 
     </servlet> 
     <servlet-mapping>
          <servlet-name>ReverseServlet</servlet-name> 
          <url-pattern>/*.do</url-pattern> 
     </servlet-mapping> 
</web-app>


推荐答案


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

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. 您的 web.xml 至少声明不符合Servlet 3.0。

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

您的servlet容器至少不支持Servlet 3.0。

Your servlet container does not support at least Servlet 3.0.

/ WEB-INF / lib 中有旧版本的servlet容器特定库。

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

要解决此问题,


  1. 确保您的 web.xml root声明符合Servlet 3.0:

  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>


  • 确保部署到Servlet 3.0兼容容器。如果JBoss AS 至少版本6.0.0。

    确保您没有这些库 / WEB-INF / lib中。他们不属于那里。这是一个常见的初学者错误,解决他们在IDE中遇到的编译错误。另请参见如何导入javax我的Eclipse项目中的.servlet API?

    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?

    你已宣布你的 web.xml 符合Servlet 2.2。这绝对是错误的。相应地修复它。

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

    这篇关于java.lang.NoSuchMethodError:javax.servlet.ServletContext.getEffectiveSessionTrackingModes()Ljava / util / Set;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆