用struts2+jsp做个网站,到了网站制作后期时,启动tomcat竟然无法启动,挂了。之前一直有用可是今天添加了一些东西就挂了,删除之后还是无法启动tomcat服务器。
下面是报错的代码:
<span style="color:#ff0000;"> org.apache.catalina.core.StandardContext filterStart SEVERE: Exception starting filter struts</span> <span style="color:#ff0000;">include - file:/C:/tomcat7.059/webapps/MusicWeb/WEB-INF/classes/struts.xml:41:43</span> at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:833) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:864) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadDocuments(XmlConfigurationProvider.java:131) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.init(XmlConfigurationProvider.java:100) at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reload(DefaultConfiguration.java:130) at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:52) at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:395) at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:452) at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:201) at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260) at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4854) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5542) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.StandardContext.reload(StandardContext.java:4033) at org.apache.catalina.startup.HostConfig.reload(HostConfig.java:1479) at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1462) at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1646) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:328) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90) at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1374) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1546) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1556) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1524) at java.lang.Thread.run(Thread.java:722) Caused by: Connection timed out: connect - [unknown location] at com.opensymphony.xwork2.util.DomHelper.parse(DomHelper.java:123) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:830) ... 26 more Caused by: java.net.ConnectException: Connection timed out: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:69) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391) at java.net.Socket.connect(Socket.java:579) at java.net.Socket.connect(Socket.java:528) at sun.net.NetworkClient.doConnect(NetworkClient.java:180) at sun.net.www.http.HttpClient.openServer(HttpClient.java:378) at sun.net.www.http.HttpClient.openServer(HttpClient.java:473) at sun.net.www.http.HttpClient.<init>(HttpClient.java:203) at sun.net.www.http.HttpClient.New(HttpClient.java:290) at sun.net.www.http.HttpClient.New(HttpClient.java:306) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:995) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:931) at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:849) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1299) at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:632) at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:1270) at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity(XMLEntityManager.java:1237) at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource(XMLDTDScannerImpl.java:260) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(XMLDocumentScannerImpl.java:1153) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(XMLDocumentScannerImpl.java:1049) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:962) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:607) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:489) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:835) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1210) at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:568) at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:302) at com.opensymphony.xwork2.util.DomHelper.parse(DomHelper.java:121) ... 27 more <span style="color:#ff0000;">四月 09, 2015 9:23:59 上午 org.apache.catalina.core.StandardContext startInternal SEVERE: Error filterStart 四月 09, 2015 9:23:59 上午 org.apache.catalina.core.StandardContext startInternal SEVERE: Context [/MusicWeb] startup failed due to previous errors</span>
导入的jar包:(网上说 少了jar包或是多了jar包 ,之前都有用,后来也适当改了一些jar包还是没用)
web.xml的配置:(提示说是过滤器Filter的问题,可是我没用到什么过滤器呀)
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <!-- org.apache.struts2.dispatcher.FilterDispatcher org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter --> <filter> <filter-name>struts</filter-name> <filter-class> org.apache.struts2.dispatcher.FilterDispatcher </filter-class> </filter> <filter-mapping><span style="color:#ff0000;"> </span><filter-name>struts</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <display-name></display-name> <welcome-file-list> <welcome-file>login.jsp</welcome-file> </welcome-file-list> <error-page> <error-code>404</error-code> <location>/error.jsp</location> </error-page> </web-app>
谁知第二天打开电脑,重启tomcat服务器 竟然没有挂,工程也可以部署,一切都正常。(注:原来添加的内容删除了)
然后我又要接着做昨天的东西,终于发现服务器报上面错误的原因了,在我的struts.xml配置文件中
<action name="multiFileUpload_*" class="com.action.UploadAction" method="{1}"> <result name="addMusicInfo" type="redirect-action">另一个Action的方法</result>如果这样写就会出现上面的错误 </action>
把<span style="color:#ff0000;"><result name="addMusicInfo" type="redirect-action"></span>另一个Action的方法</result> 改成 <span style="color:#ff0000;"><result name="addMusicInfo" >/error.jsp</result></span> 就不会报错 ,并且报错之后,改回来了服务器还是无法启动。 出现问题的原因找到了,但是为什么出现以及如何解决还不清楚,希望有出错的可以一起探讨下
补充下出错时的日志文件:
127.0.0.1 - - [09/Apr/2015:09:19:36 +0800] "GET /gg_bd_ad_720x90.js HTTP/1.1" 404 - 127.0.0.1 - - [09/Apr/2015:09:19:36 +0800] "GET /follow.js HTTP/1.1" 404 - 127.0.0.1 - - [09/Apr/2015:09:19:36 +0800] "GET /MusicWeb/upload//%E5%87%BA%E9%94%99%E5%A3%81%E7%BA%B8.jpg HTTP/1.1" 304 -