標籤:http java os io 檔案 ar 2014 art
SSH項目
在網路複雜的情況(具體規律未知)下,Tomcat啟動時,報如下錯誤:
[ERROR] 2014-08-12 14:52:58,484 [org.apache.struts2.dispatcher.Dispatcher :27] - Dispatcher initialization failed
Unable to load configuration. - Class: java.net.AbstractPlainSocketImpl
File: AbstractPlainSocketImpl.java
Method: connect
Line: 178 - java/net/AbstractPlainSocketImpl.java:178:-1
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:58)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:374)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:418)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:275)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3709)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4363)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: Unable to load file:/E:/Work/workspace/ws4szzt71/TheThirdAffiliatedHospitalOfSunYatsenUniversity/WebRoot/WEB-INF/classes/struts.xml - Class: java.net.AbstractPlainSocketImpl
File: AbstractPlainSocketImpl.java
Method: connect
Line: 178 - java/net/AbstractPlainSocketImpl.java:178:-1
解決方案如下:
報錯資訊提示無法load:struts.xml檔案。
查看struts.xml檔案的DOCTYPE定義發現版本與struts2-core-2.1.8.1.jar不一致,作如下修改:
將struts.xml中的聲明部分修改為工程所用jar包struts2-core-2.1.8.1.jar中struts-default.xml的檔案聲明即可。
即
將:<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd">
修改為:<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN" "http://struts.apache.org/dtds/struts-2.1.7.dtd">