tomcat 7.x 报错javax.servlet.ServletContext.getSessionCookieConfig

下了个tomcat7 bata试用了下,结果默认的直接启动,报错

错误消息:

2010-11-13 20:12:08 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory docs
2010-11-13 20:12:08 org.apache.catalina.startup.HostConfig deployDirectory
严重: Error deploying web application directory docs
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.java:1283)
 at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:881)
 at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:315)
 at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
 at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
 at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4700)
 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
 at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:810)
 at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:788)
 at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:558)
 at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1051)
 at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:977)
 at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:507)
 at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1322)
 at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:307)
 at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
 at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
 at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:325)
 at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:305)
 at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1036)
 at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:773)
 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
 at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1028)
 at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:278)
 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
 at org.apache.catalina.core.StandardService.startInternal(StandardService.java:429)
 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
 at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:662)
 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
 at org.apache.catalina.startup.Catalina.start(Catalina.java:592)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.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(该链接无法打开--作者注)

 原文地址:http://blog.sina.com.cn/s/blog_63a74b750100qza3.html

你可能感兴趣的:(java,tomcat,servlet,native)