. lang。NoSuchMethodError:javax.servlet.ServletContext.getSessionCookieConfig()

时间:2021-10-17 19:39:50

When i'm launching the Tomcat server it gives the following error:

当我启动Tomcat服务器时,它会出现以下错误:

Server Tomcat v7.0 Server at localhost failed to start

本地主机的Tomcat v7.0服务器启动失败

The errors obtained in the console are:

控制台的错误是:

SEVERE: A child container failed during start java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]] at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222) at java.util.concurrent.FutureTask.get(FutureTask.java:83) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:800) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619) Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) ... 7 more Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getSessionCookieConfig()Ljavax/servlet/SessionCookieConfig; at org.apache.catalina.deploy.WebXml.configureContext(WebXml.java:1374) at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1346) at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:878) at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:376) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5322) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ... 7 more

serious:在start java.util.concurrent中,一个子容器失败了。ExecutionException:org.apache.catalina。LifecycleException:未能启动组件[标准引擎[Catalina]. standardhost [localhost]。在java.util. concurrentl . futuretask $Sync.innerGet(FutureTask.java:222) at java.util. concurrentl . futuretas .get(futuretas .java:83) at org. apachc .catalina.core. core. core在java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138)在java.util.concurrent. thread . runtask . runtask (ThreadPoolExecutor.java:886) at java.util.concurrent. thread . runtask .run(ThreadPoolExecutor.java:908)在java.lang.Thread.run(Thread.java:619)中,由:org. apache.t。LifecycleException:未能启动组件[StandardEngine[Catalina]. standardhost [localhost]。在org.apache.catalina.util.LifecycleBase.start StandardContext[]](LifecycleBase.java:154)……更多的原因:java.lang。NoSuchMethodError:javax.servlet.ServletContext.getSessionCookieConfig()Ljavax / servlet / SessionCookieConfig;在org.apache.c recontext .apache.c recontext (WebXml.java:1374) .apache.c arina.startup.c . contextconfig (ContextConfig.java:1346) org.apache.corg.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5322)org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)…7多

It will be grateful if someone could share the solution. Thanks!

如果有人能分享解决方案,我将不胜感激。谢谢!

Web.xml:

web . xml:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee   http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <display-name />
    <listener>
        <listener-class>
            org.springframework.web.context.request.RequestContextListener
        </listener-class>
    </listener>
    <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>
    <filter>
        <description>generated-persistence-filter</description>
        <filter-name>hrbFilter</filter-name>
        <filter-class>
            org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter
        </filter-class>
        <init-param>
            <param-name>entityManagerFactoryBeanName</param-name>
            <param-value>hrb</param-value>
        </init-param>
    </filter>
    <filter>
        <description>generated-sitemesh-filter</description>
        <filter-name>Sitemesh Filter</filter-name>
        <filter-class>
            com.opensymphony.module.sitemesh.filter.PageFilter
        </filter-class>
    </filter>
    <filter-mapping>
        <filter-name>hrbFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>Sitemesh Filter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <servlet>
        <description>generated-servlet</description>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet>
        <description>generated-servlet</description>
        <servlet-name>PrimeFaces Resource Servlet</servlet-name>
        <servlet-class>
            org.primefaces.resource.ResourceServlet
        </servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet>
        <description>generated-servlet</description>
        <servlet-name>hr_demo Servlet</servlet-name>
        <servlet-class>
            org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:hr_demo-web-context.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet>
        <description>generated-resources-servlet</description>
        <servlet-name>Resource Servlet</servlet-name>
        <servlet-class>
            org.springframework.js.resource.ResourceServlet
        </servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>PrimeFaces Resource Servlet</servlet-name>
        <url-pattern>/primefaces_resource/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>Resource Servlet</servlet-name>
        <url-pattern>/resources/*</url-pattern>
    </servlet-mapping>
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>server</param-value>
    </context-param>
    <context-param>
        <param-name>com.sun.faces.expressionFactory</param-name>
        <param-value>com.sun.el.ExpressionFactoryImpl</param-value>
    </context-param>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
</web-app>

2 个解决方案

#1


0  

Seems like a classpath issue. Make sure there isn't a servlet.jar in the classpath other than the one already included in Tomcat_HOME/lib

似乎是类路径问题。确保没有servlet。除了在Tomcat_HOME/lib中已经包含的以外,在类路径中的jar。

#2


0  

Write localhost:yourportnumber on your web browser. Is your Tomcat server working? If Tomcat server is not working on your web browser, you could not load Tomcat server correctly, try again and click startup.bat under the C:\tomcat\bin.

在web浏览器上写入localhost:yourportnumber。您的Tomcat服务器是否正常工作?如果Tomcat服务器没有在web浏览器上工作,您无法正确地加载Tomcat服务器,请再次尝试并单击startup。蝙蝠在C:\ tomcat \ bin。

If Tomcat server is working correctly, put Tomcat folder on C:/Tomcat. And show classpath (Tomcat installation directory) on your IDE.

如果Tomcat服务器工作正常,请将Tomcat文件夹放在C:/Tomcat上。并在IDE上显示classpath (Tomcat安装目录)。

#1


0  

Seems like a classpath issue. Make sure there isn't a servlet.jar in the classpath other than the one already included in Tomcat_HOME/lib

似乎是类路径问题。确保没有servlet。除了在Tomcat_HOME/lib中已经包含的以外,在类路径中的jar。

#2


0  

Write localhost:yourportnumber on your web browser. Is your Tomcat server working? If Tomcat server is not working on your web browser, you could not load Tomcat server correctly, try again and click startup.bat under the C:\tomcat\bin.

在web浏览器上写入localhost:yourportnumber。您的Tomcat服务器是否正常工作?如果Tomcat服务器没有在web浏览器上工作,您无法正确地加载Tomcat服务器,请再次尝试并单击startup。蝙蝠在C:\ tomcat \ bin。

If Tomcat server is working correctly, put Tomcat folder on C:/Tomcat. And show classpath (Tomcat installation directory) on your IDE.

如果Tomcat服务器工作正常,请将Tomcat文件夹放在C:/Tomcat上。并在IDE上显示classpath (Tomcat安装目录)。