Eclipse启动Tomcat时发生java.lang.IllegalArgumentException: <sessionconfig> element is limited to 1 occurrence

在学习struts 2时,为了方便,直接从下载的struts的apps目录下的struts2-blank.war压缩包下的WEB-INF\复制的web.xml,当我启动Tomcat时,发生

java.lang.IllegalArgumentException: <session-config> element is limited to 1 occurrence
	at org.apache.tomcat.util.descriptor.web.SetSessionConfig.begin(WebRuleSet.java:761)
	at org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1180)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
	at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1448)
	at org.apache.tomcat.util.descriptor.web.WebXmlParser.parseWebXml(WebXmlParser.java:119)
	at org.apache.catalina.startup.ContextConfig.getDefaultWebXmlFragment(ContextConfig.java:1547)
	at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1113)
	at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:783)
	at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:307)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:95)
	at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5213)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

十二月 28, 2016 7:06:58 下午 org.apache.tomcat.util.descriptor.web.WebXmlParser parseWebXml
严重: Parse error in application web.xml file at file:/S:/leaning/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/conf/web.xml
org.xml.sax.SAXParseException; systemId: file:/S:/leaning/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/conf/web.xml; lineNumber: 4678; columnNumber: 21; Error at (4678, 21) : <session-config> element is limited to 1 occurrence
	at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:1891)
	at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:1923)
	at org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1183)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
	at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1448)
	at org.apache.tomcat.util.descriptor.web.WebXmlParser.parseWebXml(WebXmlParser.java:119)
	at org.apache.catalina.startup.ContextConfig.getDefaultWebXmlFragment(ContextConfig.java:1547)
	at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1113)
	at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:783)
	at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:307)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:95)
	at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5213)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: <session-config> element is limited to 1 occurrence
	at org.apache.tomcat.util.descriptor.web.SetSessionConfig.begin(WebRuleSet.java:761)
	at org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1180)
	... 26 more

 这让我很慌啊,从没见过的,后来认真阅读错误,发现/D:/leaning/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/conf/web.xml; lineNumber: 4678; columnNumber: 21; Error at (4678, 21) : <session-config> element is limited to 1 occurrence

根据描述的找到文件/D:/leaning/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/conf/web.xml,果然有两个session-conf

<session-config>   
        <session-timeout>30</session-timeout>     
   </session-config> 

 删除一个,在重启Tomcat,问题解决。

原文地址:https://www.cnblogs.com/kingkangstudy/p/6230631.html