1

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

Server Tomcat v7.0 Server at localhost 启动失败

在控制台中得到的错误是:

303) 在 java.util.concurrent.FutureTask.run(FutureTask.java:138) 在 java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 在 java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619) 原因:org.apache.catalina.LifecycleException: 无法启动组件 [StandardEngine[Catalina].StandardHost[localhost].StandardContext[ ]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) ... 7 更多原因:java.lang.NoSuchMethodError: javax.servlet.ServletContext.getSessionCookieConfig()Ljavax/servlet/SessionCookieConfig; 在 org.apache.catalina.deploy.WebXml.configureContext(WebXml.java:1374) 在 org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1346) 在 org.apache。

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

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>
4

2 回答 2

0

似乎是一个类路径问题。确保类路径中除了 Tomcat_HOME/lib 中已包含的之外没有 servlet.jar

于 2013-09-02T12:02:05.017 回答
0

在您的网络浏览器上写入 localhost:yourportnumber。您的 Tomcat 服务器是否正常工作?如果 Tomcat 服务器无法在您的 Web 浏览器上运行,则可能无法正确加载 Tomcat 服务器,请重试并单击 C:\tomcat\bin 下的 startup.bat。

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

于 2013-09-02T13:35:15.600 回答