我正在将我的应用程序服务器从 Jboss 4.2 迁移到 7.1。我在 Struts 配置中收到以下错误。Action
在内部定义的struts.xml
被调用并且Action
包中存在的动作没有被调用。我还发布了我Action
的struts.xml
和堆栈跟踪:
13:56:06,503 ERROR [org.apache.struts2.dispatcher.Dispatcher] (http-localhost-127.0.0.1-8080-2) Could not find action or result: There is no Action mapped for namespace / and action name loginValidate. - [unknown location]
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:178) [xwork-core-2.1.6.jar:]
at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61) [struts2-core-2.1.8.1.jar:]
at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39) [struts2-core-2.1.8.1.jar:]
at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:47) [xwork-core-2.1.6.jar:]
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:478) [struts2-core-2.1.8.1.jar:]
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) [struts2-core-2.1.8.1.jar:]
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91) [struts2-core-2.1.8.1.jar:]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:147) [spring-orm-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) [spring-web-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_20]
我的Struts.xml
:
<constant name="struts.convention.action.packages" value="com.infotech.project.web.action" />
<constant name="struts.convention.package.locators" value="actions,action" />
<constant name="struts.convention.result.path" value="/WEB-INF/jsp" />
<constant name="struts.convention.default.parent.package" value="project" />
<package name="default" namespace="/" extends="struts-default,json-default" />
<constant name="struts.devMode" value="true" />
<package name="project"
extends="struts-default,json-default,jfreechart-default, jasperreports-default"
namespace="/">
<!-- more action names goes here -->
</package>
我的LoginAction.java
:
package com.infotech.project.web.action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
@SuppressWarnings("serial")
@Result(type="json")
public class LoginAction extends ActionSupport implements SessionAware {
@SuppressWarnings("unchecked")
@SkipValidation
@Action(value = "/loginValidate", results = { @Result(name = "success", params = {"ignoreHierarchy","false"}) })
public String validateUserLogin() {
// validation code goes here
}
}
更新到 Struts 2.3.4 后:
ERROR [com.opensymphony.xwork2.util.finder.ClassFinder] (MSC service thread 1-1) Unable to read class [com.lntinfotech.virtuoso.web.action.DttjoinAction]: java.lang.NoClassDefFoundError: com/opensymphony/xwork2/util/finder/ClassFinder$InfoBuildingVisitor
at com.opensymphony.xwork2.util.finder.ClassFinder.readClassDef(ClassFinder.java:782) [xwork-core-2.3.4.jar:2.3.4]
at com.opensymphony.xwork2.util.finder.ClassFinder.<init>(ClassFinder.java:165) [xwork-core-2.3.4.jar:2.3.4]
at org.apache.struts2.convention.PackageBasedActionConfigBuilder.findActions(PackageBasedActionConfigBuilder.java:386) [struts2-convention-plugin-2.3.4.jar:2.3.4]
at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildActionConfigs(PackageBasedActionConfigBuilder.java:344) [struts2-convention-plugin-2.3.4.jar:2.3.4]
at org.apache.struts2.convention.ClasspathPackageProvider.loadPackages(ClasspathPackageProvider.java:53) [struts2-convention-plugin-2.3.4.jar:2.3.4]
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:245) [xwork-core-2.3.4.jar:2.3.4]
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66) [xwork-core-2.3.4.jar:2.3.4]
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:390) [struts2-core-2.3.4.jar:2.3.4]
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:437) [struts2-core-2.3.4.jar:2.3.4]
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74) [struts2-core-2.3.4.jar:2.3.4]
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51) [struts2-core-2.3.4.jar:2.3.4]
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:447) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3269) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3865) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_20]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_20]
at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_20]