6

由于某种奇怪的原因,我在启动 tomcat 时遇到了问题,它以前启动时没有问题。错误太长了,我无法从命令提示符完全复制它。有谁知道可能出了什么问题?

    C:\apache-tomcat-7.0.8\bin>catalina.bat start

    Using CATALINA_BASE:   "C:\apache-tomcat-7.0.8"
    Using CATALINA_HOME:   "C:\apache-tomcat-7.0.8"
    Using CATALINA_TMPDIR: "C:\apache-tomcat-7.0.8\temp"

    Using JRE_HOME:        "C:\Program Files (x86)\Java\jdk1.6.0_23"
    Using CLASSPATH:       "C:\apache-tomcat-7.0.8\bin\bootstrap.jar;C:\apache-tomca
    t-7.0.8\bin\tomcat-juli.jar"



            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
            at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.ja
    va:1035)

            at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.
    java:291)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
            at org.apache.catalina.core.StandardService.startInternal(StandardServic

    e.java:443)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
            at org.apache.catalina.core.StandardServer.startInternal(StandardServer.
    java:724)

            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
            at org.apache.catalina.startup.Catalina.start(Catalina.java:620)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)

            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:304)
            at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)

    12-Apr-2011 8:02:23 PM org.apache.catalina.startup.HostConfig deployDirectory
    INFO: Deploying web application directory examples
    12-Apr-2011 8:02:23 PM org.apache.catalina.startup.HostConfig deployDirectory

    SEVERE: Error deploying web application directory examples
    java.lang.NoSuchMethodError: javax.servlet.ServletContext.getSessionCookieConfig
    ()Ljavax/servlet/SessionCookieConfig;
            at org.apache.catalina.deploy.WebXml.configureContext(WebXml.java:1281)

            at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.jav
    a:1276)
            at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfi
    g.java:874)

            at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfi
    g.java:317)
            at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
    eSupport.java:119)

            at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBa
    se.java:89)
            at org.apache.catalina.core.StandardContext.startInternal(StandardContex
    t.java:4974)

            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
            at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
    .java:812)
            at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:78

    7)
            at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:607)

            at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.jav
    a:1044)

            at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.j
    ava:967)
            at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:472
    )
            at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1302)

            at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
    :311)
            at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
    eSupport.java:119)

            at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBa
    se.java:89)
            at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:34
    3)

            at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:32
    3)
            at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.ja
    va:1043)
            at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java

    :774)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
            at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.ja
    va:1035)
            at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.

    java:291)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
            at org.apache.catalina.core.StandardService.startInternal(StandardServic
    e.java:443)

            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
            at org.apache.catalina.core.StandardServer.startInternal(StandardServer.
    java:724)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

            at org.apache.catalina.startup.Catalina.start(Catalina.java:620)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.

    java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:304)

            at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)
    12-Apr-2011 8:02:23 PM org.apache.catalina.startup.HostConfig deployDirectory
    INFO: Deploying web application directory host-manager

    12-Apr-2011 8:02:23 PM org.apache.catalina.startup.HostConfig deployDirectory
    SEVERE: Error deploying web application directory host-manager
    java.lang.NoSuchMethodError: javax.servlet.ServletContext.getSessionCookieConfig

    ()Ljavax/servlet/SessionCookieConfig;
            at org.apache.catalina.deploy.WebXml.configureContext(WebXml.java:1281)
            at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.jav

    a:1276)
            at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfi
    g.java:874)
            at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfi

    g.java:317)
            at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
    eSupport.java:119)
            at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBa

    se.java:89)
            at org.apache.catalina.core.StandardContext.startInternal(StandardContex
    t.java:4974)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

            at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
    .java:812)
            at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:78
    7)
            at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:607)


            at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.jav
    a:1044)
            at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.j
    ava:967)

            at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:472
    )
            at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1302)
            at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java

    :311)
            at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
    eSupport.java:119)
            at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBa

    se.java:89)
            at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:34
    3)
            at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:32

    3)
            at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.ja
    va:1043)
            at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java
    :774)

            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
            at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.ja
    va:1035)
            at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.

    java:291)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
            at org.apache.catalina.core.StandardService.startInternal(StandardServic
    e.java:443)

            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
            at org.apache.catalina.core.StandardServer.startInternal(StandardServer.
    java:724)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

            at org.apache.catalina.startup.Catalina.start(Catalina.java:620)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.

    java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:304)

            at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)
    12-Apr-2011 8:02:23 PM org.apache.catalina.startup.HostConfig deployDirectory
    INFO: Deploying web application directory manager

    12-Apr-2011 8:02:23 PM org.apache.catalina.startup.HostConfig deployDirectory
    SEVERE: Error deploying web application directory manager
    java.lang.NoSuchMethodError: javax.servlet.ServletContext.getSessionCookieConfig

    ()Ljavax/servlet/SessionCookieConfig;
            at org.apache.catalina.deploy.WebXml.configureContext(WebXml.java:1281)
            at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.jav

    a:1276)
            at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfi
    g.java:874)
            at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfi

    g.java:317)
            at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
    eSupport.java:119)
            at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBa

    se.java:89)
            at org.apache.catalina.core.StandardContext.startInternal(StandardContex
    t.java:4974)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

            at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
    .java:812)
            at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:78
    7)
            at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:607)


            at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.jav
    a:1044)
            at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.j
    ava:967)

            at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:472
    )
            at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1302)
            at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java

    :311)
            at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
    eSupport.java:119)
            at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBa

    se.java:89)
            at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:34
    3)
            at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:32

    3)
            at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.ja
    va:1043)
            at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java
    :774)

            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
            at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.ja
    va:1035)
            at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.

    java:291)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
            at org.apache.catalina.core.StandardService.startInternal(StandardServic
    e.java:443)

            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
            at org.apache.catalina.core.StandardServer.startInternal(StandardServer.
    java:724)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

            at org.apache.catalina.startup.Catalina.start(Catalina.java:620)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.

    java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:304)

            at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)
    12-Apr-2011 8:02:23 PM org.apache.catalina.startup.HostConfig deployDirectory
    INFO: Deploying web application directory ROOT

    12-Apr-2011 8:02:23 PM org.apache.catalina.startup.HostConfig deployDirectory
    SEVERE: Error deploying web application directory ROOT
    java.lang.NoSuchMethodError: javax.servlet.ServletContext.getSessionCookieConfig

    ()Ljavax/servlet/SessionCookieConfig;
            at org.apache.catalina.deploy.WebXml.configureContext(WebXml.java:1281)
            at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.jav

    a:1276)
            at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfi
    g.java:874)
            at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfi

    g.java:317)
            at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
    eSupport.java:119)
            at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBa

    se.java:89)
            at org.apache.catalina.core.StandardContext.startInternal(StandardContex
    t.java:4974)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

            at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
    .java:812)
            at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:78
    7)
            at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:607)


            at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.jav
    a:1044)
            at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.j
    ava:967)

            at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:472
    )
            at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1302)
            at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java

    :311)
            at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
    eSupport.java:119)
            at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBa

    se.java:89)
            at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:34
    3)
            at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:32

    3)
            at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.ja
    va:1043)
            at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java
    :774)

            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
            at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.ja
    va:1035)
            at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.

    java:291)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
            at org.apache.catalina.core.StandardService.startInternal(StandardServic
    e.java:443)

            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
            at org.apache.catalina.core.StandardServer.startInternal(StandardServer.
    java:724)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

            at org.apache.catalina.startup.Catalina.start(Catalina.java:620)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.

    java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:304)

            at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)
    12-Apr-2011 8:02:23 PM org.apache.coyote.AbstractProtocolHandler start
    INFO: Starting ProtocolHandler ["http-apr-8080"]

    12-Apr-2011 8:02:23 PM org.apache.coyote.AbstractProtocolHandler start
    INFO: Starting ProtocolHandler ["ajp-apr-8009"]
    12-Apr-2011 8:02:23 PM org.apache.catalina.startup.Catalina start

    INFO: Server startup in 801 ms
4

3 回答 3

11
Error Message: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getSessionCookieConfig()
Ljavax/servlet/SessionCookieConfig;

症状:Tomcat无法启动

可能原因:这是Servlets 3.0Tomcat 7支持)中的一种新方法。有一个Servlets 2.x API是你的CLASSPATHJDK's扩展目录。解决方案:检查您的CLASSPATH. servlet-api.jar如果有的话,从JDK's扩展目录中删除。

资料来源:http ://www3.ntu.edu.sg/home/ehchua/programming/howto/Tomcat_HowTo.html

于 2011-04-13T06:34:11.947 回答
1

我通过将以下 jars 添加到我的 tomcat/lib 目录中解决了这个确切的错误:

javax.persistence-2.0.0.jar

持久性-api-1.0.2.jar

您可以在这里找到最新版本:http: //mvnrepository.com/

于 2012-03-21T20:11:40.087 回答
0

如果您编译了一个包含其运行时依赖项的 jar,并且引用了旧版本的 tomcat servlet-api.jar,也会发生这种情况。

那么当你的jar在不同版本的Tomcat中加载时,servlet api不正确,就会抛出这个错误。

因此,请检查您的 jar 是如何编译的,并确保它不以某种方式将 servlet-api.jar 作为依赖项包含在内!

于 2016-09-02T12:47:43.027 回答