tomcat 7.x 报错javax.servlet.ServletContext.getSessionCookieConfig
下了个tomcat7 bata试用了下,结果默认的直接启动,报错
错误消息:
2010-11-13 20:12:08 org.apache.catalina.startup.HostConfig deployDirectory
信息:Deployingwebapplicationdirectorydocs
2010-11-1320:12:08org.apache.catalina.startup.HostConfigdeployDirectory
严重:Errordeployingwebapplicationdirectorydocs
java.lang.NoSuchMethodError:javax.servlet.ServletContext.getSessionCookieConfig()Ljavax/servlet/SessionCookieConfig;
atorg.apache.catalina.deploy.WebXml.configureContext(WebXml.java:1281)
atorg.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1283)
atorg.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:881)
atorg.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:315)
atorg.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
atorg.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
atorg.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4700)
atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
atorg.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:810)
atorg.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:788)
atorg.apache.catalina.core.StandardHost.addChild(StandardHost.java:558)
atorg.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1051)
atorg.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:977)
atorg.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:507)
atorg.apache.catalina.startup.HostConfig.start(HostConfig.java:1322)
atorg.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:307)
atorg.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
atorg.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
atorg.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:325)
atorg.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:305)
atorg.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1036)
atorg.apache.catalina.core.StandardHost.startInternal(StandardHost.java:773)
atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
atorg.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1028)
atorg.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:278)
atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
atorg.apache.catalina.core.StandardService.startInternal(StandardService.java:429)
atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
atorg.apache.catalina.core.StandardServer.startInternal(StandardServer.java:662)
atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
atorg.apache.catalina.startup.Catalina.start(Catalina.java:592)
atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)
atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
atjava.lang.reflect.Method.invoke(Method.java:597)
atorg.apache.catalina.startup.Bootstrap.start(Bootstrap.java:290)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:418)可以看出是读写配置文件出错,原来是servlet3.0的包的错误,tomcat7在运行的时候,使用的不是自己lib下面的那个api,而是使用的
这个目录下的jdk1.6.0_10\jre\lib\ext
只要把这个下面的servlet-api.jar替换成tomcat7下面的那个jar包文件,启动就正常了
下面这篇文章对于配置讲解很详细:
http://www3.ntu.edu.sg/home/ehchua/programming/howto/Tomcat7_HowTo.html