使用 struts 的 Web 应用程序中的 ClassNotFoundException
我正在使用 Apache Struts 开发一个 Web 应用程序,并将其部署在 JBoss 服务器上。使用eclipse进行开发。
我已配置 web.xml 将所有 *.do 请求转发到 ActionServlet。
JSP 页面 (abc.jsp) 具有一个带有 action="newgoal.do" 的表单。
struts-config.xml 文件具有以下条目:
<action path="/newgoal" type="com.misys.trng.AddingNewGoalAction">
</action>
我已验证该类的路径是否正确。
我的网络应用程序中的所有其他 .do 转发都工作得很好。 当我从 abc.jsp 提交表单时,出现以下异常:
2:13:43,793 ERROR [RequestProcessor] No action instance for path /newgoal could be created
java.lang.ClassNotFoundException: com.misys.trng.AddingNewGoalAction
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.apache.struts.util.RequestUtils.applicationClass(RequestUtils.java:117)
at org.apache.struts.util.RequestUtils.applicationInstance(RequestUtils.java:143)
at org.apache.struts.action.RequestProcessor.processActionCreate(RequestProcessor.java:280)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:218)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
我无法理解错误可能是什么。为什么我的应用程序无法加载 1 个特定类,而其他所有类都工作正常。请帮忙。
I am developing a web application using Apache Struts, to be deployed on JBoss Server. Using eclipse for development.
I have configured web.xml to forward all *.do requests to ActionServlet.
A JSP page (abc.jsp) has a form with action="newgoal.do".
The struts-config.xml file has the following entry:
<action path="/newgoal" type="com.misys.trng.AddingNewGoalAction">
</action>
I have verified that the path of the class is correct.
All other .do forwards in my web application are working perfectly fine.
When I submit the form from abc.jsp, I get the following exception:
2:13:43,793 ERROR [RequestProcessor] No action instance for path /newgoal could be created
java.lang.ClassNotFoundException: com.misys.trng.AddingNewGoalAction
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.apache.struts.util.RequestUtils.applicationClass(RequestUtils.java:117)
at org.apache.struts.util.RequestUtils.applicationInstance(RequestUtils.java:143)
at org.apache.struts.action.RequestProcessor.processActionCreate(RequestProcessor.java:280)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:218)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
I cannot fathom what the error could be. Why isn't my application able to load 1 particular class, when all others are working fine. Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该类必须存在于
WEB-INF/classes
下,或者位于WEB-INF/lib
下的 .jar 文件内。确保它确实如此。The class must exist under
WEB-INF/classes
or be inside a .jar file underWEB-INF/lib
. Make sure it does.也许你的动作中有些东西是静态的?我也有同样的问题。使用不存在的属性中的值初始化一个静态变量,然后不初始化操作。
Perhaps something is static in your action? I had the same problem. One static variable was initialized with a value in properties that did not exist, then the action not is initialized.