在使用struts編程時出現下例錯誤,總結網上解決方法,彙總如下
嚴重: Dispatcher initialization failed
Unable to load configuration.
報上面錯誤的原因有多種,得看後面提示是什麼原因引起的,再動手
解決。
*****************************************
情況一:
嚴重: Dispatcher initialization failed
Unable to load configuration. - action - file:/D:/Program
%20Files/Tomcat7.0/webapps/sshtest1/WEB-
INF/classes/struts.xml:8:83
......
Caused by: Action class [com.lib.action.Loginactionr] not
found
上面說struts.xml第8行出現錯誤,看後面提示說是Action class找
不到,
解決方法1:查看struts.xml中的第8行代碼,看看類的包或類名是否
正確
解決方法2:在項目名處右鍵->build path->configure Build
Path...->Libraries
看看有沒有打錯標記的包
解決方法3:有時因不明原因造成服器上的文件沒有更新,引起報同
樣的錯誤。所以將項目從Tomcat服務器從刪除,並重新發布到Tomcat
服務器上。
解決方法4:打開服務器查看相關的文件在不在,如文件
[com.lib.action.Loginaction]中的Loginaction在不在服務器對應
的文件夾內;
***********************************************
情況二:
嚴重: Dispatcher initialization failed
Unable to load configuration. - bean - jar:file:/D:/apache-
tomcat-6.0.29/webapps/myKj/WEB-INF/lib/struts2-spring-
plugin-2.1.8.1.jar!/struts-plugin.xml:29:132
說明錯誤在struts-plugin.xml的第29行
解決方法:
這個是因爲多加了struts2-spring-plugin-2.1.8.1.jar,這個包,
沒有用到spring的時候不要加。刪掉
****************************************************
情況三:
嚴重: Dispatcher initialization failed
Unable to load configuration. - bean - jar:file:/C:/Program
Files/Apache Software Foundation/Tomcat
6.0/webapps/Struts2Demo01/WEB-INF/lib/struts2-core-
2.1.8.jar!/struts-default.xml:47:178
解決方法:
除了
commons-logging-1.0.4.jar
freemarker-2.3.12.jar
ognl-2.6.11.jar
struts2-core-2.1.2.jar
xwork-2.1.1.jar
這五個核心LIB要複製外,
commons-io-1.3.2.jar
commons-fileupload-1.2.1.jar
這兩個Jar文件也必須放到指定目錄
*************************************
錯誤總結
1.使用了沒有用到的包;
2.struts2.xml 配置文件中類的名稱(包名+類名)錯誤;
3.服務器中的配置文件沒有更新,還是以前錯誤的文件;
4.服務器中沒有相應的文件;
5.相關的包沒有導入項目中;