香帅 2010-12-23
今天在做SSI框架整合的时候报了一个这样的错误:Actionclass[userAction]notfound-action-file:/D:/tomcat-6.0.29/webapps/SSIBlank/WEB-INF/classes/struts.xml:10:54,找了好久,一直以为我配置的问题或者是缓存的原因,翻来覆去搞了好久也没搞好,最后想想...原来是这样,具体的异常详细信息如下:
严重:ExceptionstartingfilterStruts2.1
Unabletoloadconfiguration.-action-file:/D:/tomcat-6.0.29/webapps/SSIBlank/WEB-INF/classes/struts.xml:10:54
atorg.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:431)
atorg.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
atorg.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
atorg.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)
atorg.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)
atorg.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)
atorg.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4001)
atorg.apache.catalina.core.StandardContext.start(StandardContext.java:4651)
atorg.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
atorg.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
atorg.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
atorg.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1041)
atorg.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:964)
atorg.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
atorg.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
atorg.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
atorg.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
atorg.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
atorg.apache.catalina.core.StandardHost.start(StandardHost.java:785)
atorg.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
atorg.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
atorg.apache.catalina.core.StandardService.start(StandardService.java:519)
atorg.apache.catalina.core.StandardServer.start(StandardServer.java:710)
atorg.apache.catalina.startup.Catalina.start(Catalina.java:581)
atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)
atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
atjava.lang.reflect.Method.invoke(Method.java:597)
atorg.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
atorg.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Causedby:Unabletoloadconfiguration.-action-file:/D:/tomcat-6.0.29/webapps/SSIBlank/WEB-INF/classes/struts.xml:10:54
atcom.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:58)
atorg.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:374)
atorg.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:418)
...29more
Causedby:Actionclass[userAction]notfound-action-file:/D:/tomcat-6.0.29/webapps/SSIBlank/WEB-INF/classes/struts.xml:10:54
atcom.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyAction(XmlConfigurationProvider.java:409)
atcom.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:354)
atcom.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:468)
atcom.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:264)
atorg.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:111)
atcom.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:193)
atcom.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)
...31more
面对出现异常的情况一定要冷静的心态,不要看报了一大串异常就觉得无从下手,感到心烦意乱,其实报的异常越多说明你出现的问题越容易找(这是我自己的观点),哈哈...在看异常的时候抓住最后的Causedby,这才是引起异常的最终原因。
下来看我们这个异常:
检查步骤:
1、看看你struts.xml文件中action中对应的class属性的值是否可以在Spring的配置文件中找到对应的id值。
2、如果你确定你的配置没有出现问题,那么一定是你导入包的时候少了包,这时候你检查下你的项目中是否有以下三个jar包,struts2-spring-plugin-2.0.11.1.jar、commons-fileupload-1.2.1.jar和commons-io-1.3.2.jar。
3、导入jar包之后如果还是有同样的错误,这时候你需要清理缓存或者把项目重新部署下,这样应该就可以解决问题了。