Caused by: Action class [java.Action] not found - action - file:/C:/Program
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Caused by: Action class [java.Action] not found - action - file:/C:/Program相关的知识,希望对你有一定的参考价值。
刚开始学习struts2,照书上写了一个小工程,结果这个错误始终搞不定,
og4j:WARN No appenders could be found for logger (com.opensymphony.xwork2.util.fs.DefaultFileManagerFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
2014-9-17 1:15:11 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter struts2
Unable to load configuration. - action - file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%207.0/webapps/Login/WEB-INF/classes/struts.xml:11:62
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:501)
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)
。。。。。。
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1524)
at java.lang.Thread.run(Thread.java:619)
Caused by: Unable to load configuration. - action - file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%207.0/webapps/Login/WEB-INF/classes/struts.xml:11:62
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:445)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:489)
... 19 more
Caused by: Action class [java.Action] not found - action -
file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%207.0/webapps/Login/WEB-INF/classes/struts.xml:11:62
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyAction(XmlConfigurationProvider.java:482)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:426)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:552)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:292)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:112)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:258)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
... 21 more
按下ctrl后点击“java.Action”也能跳转,,,jar包也都导进去了,就是不行,哎,,,
问题已经解决了,是放action的包的名字“java”的问题,改成其他的任意一个就好了。
你把项目放在 没有空格的路径里
file:/C:/Program%20Files/Apache%20Software%20Foundation 这个有空格的追问
我把Tomcat按在别的目录下还是不行,,怎么回事?
严重: Exception starting filter struts2
Unable to load configuration. - action - file:/D:/Tomcat7/webapps/Login/WEB-INF/classes/struts.xml:9:62
谢谢你的回答
你好好看看你的xml的配置吧
filter的映射,路径
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: Action class [java.Action] not found - action - file:/C:/Program的主要内容,如果未能解决你的问题,请参考以下文章
mybatis Caused by: org.apache.ibatis.reflection.ReflectionException: Error instantiating class .. wi
Caused by: java.lang.ClassNotFoundException: org.fusesource.jansi.WindowsAnsiOutputStream
Caused by: java.lang.ClassNotFoundException: Cannot find class: User
Caused by: java.lang.IncompatibleClassChangeError: class net.sf.cglib.core.DebuggingClassWriter has
Caused by: java.lang.IllegalStateException: Serialized class cn.bloghut.dto.ProducterDto must implem
android 自定义View Caused by: java.lang.ClassNotFoundException: Didn't find class