我刚刚开始学习struts2框架,中间碰到不少问题,特别是下面这一个,让我废了大概2个小时左右才解决,贴出来供大家参考一下。
参考文章:
Caused by: Action class [com.struts.action.LoginAction] not found 解决方法
https://blog.csdn.net/tomcat_2014/article/details/46136133
1, 这个是错误界面
2,下面这个是错误信息
严重: Dispatcher initialization failed
Unable to load configuration. - action - file:/D:/AMPT/apache-tomcat-7.0.52/apache-tomcat-7.0.52/webapps/struts2_crm/WEB-INF/classes/struts.xml:14:94
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:967)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:435)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:479)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57)
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.(ApplicationFilterConfig.java:105)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4809)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5485)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: Action class [cn.itheima.web.action.CustomerAction] not found - action - file:/D:/AMPT/apache-tomcat-7.0.52/apache-tomcat-7.0.52/webapps/struts2_crm/WEB-INF/classes/struts.xml:14:94
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyAction(XmlConfigurationProvider.java:486)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:429)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:556)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:295)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:112)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:264)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
... 17 more
十一月 17, 2018 10:24:47 下午 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter struts2
Unable to load configuration. - action - file:/D:/AMPT/apache-tomcat-7.0.52/apache-tomcat-7.0.52/webapps/struts2_crm/WEB-INF/classes/struts.xml:14:94
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:493)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57)
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.(ApplicationFilterConfig.java:105)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4809)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5485)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: Unable to load configuration. - action - file:/D:/AMPT/apache-tomcat-7.0.52/apache-tomcat-7.0.52/webapps/struts2_crm/WEB-INF/classes/struts.xml:14:94
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:967)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:435)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:479)
... 14 more
Caused by: Action class [cn.itheima.web.action.CustomerAction] not found - action - file:/D:/AMPT/apache-tomcat-7.0.52/apache-tomcat-7.0.52/webapps/struts2_crm/WEB-INF/classes/struts.xml:14:94
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyAction(XmlConfigurationProvider.java:486)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:429)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:556)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:295)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:112)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:264)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
... 17 more
十一月 17, 2018 10:24:47 下午 org.apache.catalina.core.StandardContext startInternal
严重: Error filterStart
十一月 17, 2018 10:24:47 下午 org.apache.catalina.core.StandardContext startInternal
严重: Context [/struts2_crm] startup failed due to previous errors
十一月 17, 2018 10:24:47 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory D:\AMPT\apache-tomcat-7.0.52\apache-tomcat-7.0.52\webapps\docs
十一月 17, 2018 10:24:49 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory D:\AMPT\apache-tomcat-7.0.52\apache-tomcat-7.0.52\webapps\examples
十一月 17, 2018 10:24:52 下午 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: contextInitialized()
十一月 17, 2018 10:24:52 下午 org.apache.catalina.core.ApplicationContext log
信息: SessionListener: contextInitialized()
十一月 17, 2018 10:24:52 下午 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@169873b')
十一月 17, 2018 10:24:52 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory D:\AMPT\apache-tomcat-7.0.52\apache-tomcat-7.0.52\webapps\host-manager
十一月 17, 2018 10:24:54 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory D:\AMPT\apache-tomcat-7.0.52\apache-tomcat-7.0.52\webapps\mail
十一月 17, 2018 10:24:57 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory D:\AMPT\apache-tomcat-7.0.52\apache-tomcat-7.0.52\webapps\manager
十一月 17, 2018 10:25:00 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory D:\AMPT\apache-tomcat-7.0.52\apache-tomcat-7.0.52\webapps\ROOT
十一月 17, 2018 10:25:02 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-bio-8080"]
十一月 17, 2018 10:25:02 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-bio-8009"]
十一月 17, 2018 10:25:02 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 21098 ms
我参考了几篇文章,可能的原因有几个:
1, struts.xml 配置文件本身有问题,
原因:有可能是Action大小写错误,或者是Action的路径有错误
解决方法:仔细核对大小写以及路径
2,struts.xml是正确的,可是在项目部署到Apache服务器中的时候,就是不能找到
原因:
解决办法: Eclipse->project->clean->选择你要清楚classess的项目
多试几次,然后 Eclipse->project-buildProject,不行就重新启动服务器,
或者上面的三个,交替进行一下,实在不行将清楚Navicator中的classess文件
重启Eclipse,直到Navigator中出现struts.xml的配置文件才OK。
多试几次,重启服务器,清楚Navicator中的classess文件,project中clean,buildProject,结合着多来几次
最后我的问题在多试几次之久就解决了。