Caused by: Unable to load configuration. - action - file:/C:/apache-tomcat-7.0.70/webapps/Structs/WE

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Caused by: Unable to load configuration. - action - file:/C:/apache-tomcat-7.0.70/webapps/Structs/WE相关的知识,希望对你有一定的参考价值。

Unable to load configuration. - action - file:/C:/apache-tomcat-7.0.70/webapps/Structs/WEB-INF/classes/struts.xml:7:72
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:431)
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.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:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5633)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1260)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:2002)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
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:/C:/apache-tomcat-7.0.70/webapps/Structs/WEB-INF/classes/struts.xml:7:72
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)
... 18 more
Caused by: Action class [cn.liuyang.action.HelloWorldAction] not found - action - file:/C:/apache-tomcat-7.0.70/webapps/Structs/WEB-INF/classes/struts.xml:7:72
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyAction(XmlConfigurationProvider.java:409)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:354)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:468)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:264)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:111)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:193)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)
... 20 more

 

这是struts错误中很经典的一个错误,今天笔者也烦了这个错误,这个错误主要的原因是配置的人没有认真地配置环境,导致服务器无法识别而产生的错误,错误产生的原因有三点:

一、缺少类包

     找到所需的jar包:发行包的lib目录中(不同版本需要的最小jar包是不同的,参见不同版本的文档。2.1.7)(至少这七个)

struts2-core.jar 核心jar包

xwork-2.jar xwork核心jar包

ognl.jar ognl表达式

freemarker.jar FreeMarker模板

commons-logging.jar 日志

commons-fileupload.jar 文件上传

commons-io.jar 文件上传依赖的包

检查包是否缺少,如果包没有缺少,那么查看第二步

二、审核struts.xml是否与所配置的类和类的包名相符

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
"http://struts.apache.org/dtds/struts-2.1.7.dtd">
<struts>
<package name="www" namespace="/test" extends="struts-default">
<action name="helloworld" class="com.www.action.HelloWorldAction" method="sayHello">
<result name="success">/1.jsp</result>
</action>
</package>
</struts>

其中,这个错误出现的原因我的是 class="com.www.action.HelloWorldAction" 这个与包的名字没有一样

技术分享

跟src下边的包名不一致,所以就会报上边的错误,所以把这个改了,就是正确的了

三、没有在web.xml的文件下配置核心控制器

<filter>

<filter-name>struts2</filter-name>

<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>

</filter>

<filter-mapping>

<filter-name>struts2</filter-name>

<url-pattern>/*</url-pattern>

</filter-mapping>

将这个配置进你的web.xml当中,<filter-name>struts2</filter-name>这个中间必须是struts2,如果写错,也会报错。

四、改完后要删除部署的记录,否则还是报错

在myeclipse下有一个D:\Users\MyEclipse 10\.metadata\.plugins\org.eclipse.core.runtime\.settings

这个路径下有一个,com.genuitec.eclipse.ast.deploy.core.prefs,还有在Tomcat的

C:\apache-tomcat-7.0.70\webapps这个路径下有

Structs.myeclipse.bak和Structs这两个文件夹,把这几个都删除了,然后关闭myeclipse,然后重启myeclipse,然后重新部署,重启启动服务器,再访问: http://localhost:8080/Structs/test/helloworld 就会配置成功

细心是程序员的基本素养,粗心的人是没法成为一个优秀的程序员的,希望对您有帮助,有疑问请留言。

 

以上是关于Caused by: Unable to load configuration. - action - file:/C:/apache-tomcat-7.0.70/webapps/Structs/WE的主要内容,如果未能解决你的问题,请参考以下文章

Caused by: Unable to load bean: type:com.opensymphony.xwork2.ObjectFactory class:org.apache.struts2.

Caused by: Unable to load bean: type:com.opensymphony.xwork2.ObjectFactory class:org.apache.struts2.

Caused by: org.springframework.context.ApplicationContextException: Unable to start ServletWebServer

SpringCloud报错:Caused by: org.springframework.context.ApplicationContextException: Unable to start Em

Caused by: org.I0Itec.zkclient.exception.ZkTimeoutException: Unable to connect to zookeeper server w

hive Caused by: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata