Struts2的行动未找到错误

Struts2的行动未找到错误

本文介绍了Struts2的行动未找到错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序服务器迁移从4.2的Jboss 7.1。我得到了Struts配置下面的错误。中定义行动的struts.xml 获取调用和动作美元的动作包p $ psent没有得到调用。我也张贴我的动作的struts.xml 键,堆栈跟踪。

  13:56:06503错误[org.apache.struts2.dispatcher.Dispatcher(HTTP-本地主机-127.0.0.1-8080-2)找不到行动或结果:有没有动作映射为命名空间/和动作名称loginValidate。 -  [未知地点]
    。在com.opensymphony.xwork2.DefaultActionProxy prepare(DefaultActionProxy.java:178)XWork的核心-2.1.6.jar:]
    。在org.apache.struts2.impl.StrutsActionProxy prepare(StrutsActionProxy.java:61)struts2的核心 - 2.1.8.1.jar:]
    在org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)struts2的核心 - 2.1.8.1.jar:]
    在com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:47) [XWork的核心-2.1.6.jar:]
    在org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:478)struts2的核心 - 2.1.8.1.jar:]
    在org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)struts2的核心 - 2.1.8.1.jar:]
    在org.apache.struts2.dispatcher.ng.filter.Struts$p$ppareAndExecuteFilter.doFilter(Struts$p$ppareAndExecuteFilter.java:91) [struts2的核心 - 2.1.8.1.jar:]
    在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)jbossweb-7.0.13.Final.jar:]
    在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)jbossweb-7.0.13.Final.jar:]
    在org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:147) [春天的ORM 3.1.2.RELEASE.jar:3.1.2.RELEASE]
    在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)弹簧网络3.1.2.RELEASE.jar:3.1.2.RELEASE]
    在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)jbossweb-7.0.13.Final.jar:]
    在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)jbossweb-7.0.13.Final.jar:]
    在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)jbossweb-7.0.13.Final.jar:]
    在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)jbossweb-7.0.13.Final.jar:]
    在org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)的jboss-AS-JPA的7.1.1.Final.jar:7.1.1.Final]
    在org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [的jboss-AS-网络7.1.1.Final.jar:7.1.1.Final]
    在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)jbossweb-7.0.13.Final.jar:]
    在org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)jbossweb-7.0.13.Final.jar:]
    在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)jbossweb-7.0.13.Final.jar:]
    在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)jbossweb-7.0.13.Final.jar:]
    在org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)jbossweb-7.0.13.Final.jar:]
    在org.apache.coyote.http11.Http11Protocol $ Http11ConnectionHandler.process(Http11Protocol.java:671)jbossweb-7.0.13.Final.jar:]
    在org.apache.tomcat.util.net.JIoEndpoint $ Worker.run(JIoEndpoint.java:930)jbossweb-7.0.13.Final.jar:]
    在java.lang.Thread.run(Thread.java:619)的rt.jar:1.6.0_20]

我的的struts.xml

 <常量名=struts.convention.action.packagesVALUE =com.infotech.project.web.action/>
<常量名=struts.convention.package.locatorsVALUE =行动,行动/>
<常量名=struts.convention.result.pathVALUE =/ WEB-INF / JSP/><常量名=struts.convention.default.parent.packageVALUE =工程/>
<包名称=默认的命名空间=/扩展=支柱默认,JSON-默认的/>
<常量名=struts.devModeVALUE =真/><包名=工程
    扩展=支柱默认,JSON-默认情况下,jfreechart的默认,JasperReports的默认
    命名空间=/>
          <! - 更多的行动名字放在这里 - >
     < /包>

我的 LoginAction.java

 包com.infotech.project.web.action;进口com.opensymphony.xwork2.ActionContext;
进口com.opensymphony.xwork2.ActionSupport;@燮pressWarnings(串行)
@Result(TYPE =JSON)
公共类的LoginAction扩展了ActionSupport实现SessionAware {
@燮pressWarnings(未登记)
@SkipValidation
@Action(值=/ loginValidate,结果= {@Result(NAME =成功,则params = {ignoreHierarchy,假})})
公共字符串validateUserLogin(){
     //验证code到这里
 }
    }

更新到2.3.4的Struts后:

 错误[com.opensymphony.xwork2.util.finder.ClassFinder(MSC服务线程1-1)无法读取类[com.lntinfotech.virtuoso.web.action.DttjoinAction ]:java.lang.NoClassDefFoundError的:COM / OpenSymphony的/ xwork2 / UTIL /取景器/ ClassFinder $ InfoBuildingVisitor
    在com.opensymphony.xwork2.util.finder.ClassFinder.readClassDef(ClassFinder.java:782)XWork的核心-2.3.4.jar:2.3.4]
    在com.opensymphony.xwork2.util.finder.ClassFinder<&初始化GT;(ClassFinder.java:165)XWork的核心-2.3.4.jar:2.3.4。
    在org.apache.struts2.convention.PackageBasedActionConfigBuilder.findActions(PackageBasedActionConfigBuilder.java:386) [struts2的会展-插件-2.3.4.jar:2.3.4]
    在org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildActionConfigs(PackageBasedActionConfigBuilder.java:344) [struts2的会展-插件-2.3.4.jar:2.3.4]
    在org.apache.struts2.convention.ClasspathPackageProvider.loadPackages(ClasspathPackageProvider.java:53) [struts2的会展-插件-2.3.4.jar:2.3.4]
    在com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:245) [XWork的核心-2.3.4.jar:2.3.4]
    在com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)XWork的核心-2.3.4.jar:2.3.4]
    在org.apache.struts2.dispatcher.Dispatcher.init_ preloadConfiguration(Dispatcher.java:390)struts2的核心-2.3.4.jar:2.3.4]
    在org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:437)struts2的核心-2.3.4.jar:2.3.4]
    在org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)struts2的核心-2.3.4.jar:2.3.4]
    在org.apache.struts2.dispatcher.ng.filter.Struts$p$ppareAndExecuteFilter.init(Struts$p$ppareAndExecuteFilter.java:51) [struts2的核心-2.3.4.jar:2.3.4]
    在org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:447)jbossweb-7.0.13.Final.jar:]
    在org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3269)jbossweb-7.0.13.Final.jar:]
    在org.apache.catalina.core.StandardContext.start(StandardContext.java:3865)jbossweb-7.0.13.Final.jar:]
    在org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90)的jboss-AS-网络7.1.1.Final.jar:7.1.1.Final]
    在org.jboss.msc.service.ServiceControllerImpl $ StartTask.startService(ServiceControllerImpl.java:1811)
    在org.jboss.msc.service.ServiceControllerImpl $ StartTask.run(ServiceControllerImpl.java:1746)
    在java.util.concurrent.ThreadPoolExecutor中的$ Worker.runTask(ThreadPoolExecutor.java:886)的rt.jar:1.6.0_20]
    在java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:908)的rt.jar:1.6.0_20]
    在java.lang.Thread.run(Thread.java:619)的rt.jar:1.6.0_20]


解决方案

我认为这个问题可能来自一个事实,即你有相同的命名空间两个包。尝试取出一包,或更改其中一个的名称空间(也许是第一个,也就是空)


编辑:

这是在 无法正常工作

正如您可以阅读,它在最新版本解决。

所以,如果你需要迁移到JBoss 7,您需要迁移到Struts的2.3.3或更高版本。

希望帮助

I am migrating my application server from Jboss 4.2 to 7.1. I am getting the following error in the Struts configuration. Action defined inside the struts.xml is getting called and the actions present in the Action packages are not getting called. I am also posting my Action, struts.xml and stacktrace.

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]

My 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>

My 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
 }
    }

After Updating to 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]
解决方案

I think the problem may come from the fact that you have two packages on the same namespace. Try removing one package, or to change the namespace of one of them (maybe the first, that is empty)


EDIT:

It is the Bug WW-3662: (Struts2) convention-plugin not work in jboss-7.0.0

As you can read, it is resolved in latest releases.

So, if you need to migrate to JBoss 7, you need to migrate to Struts 2.3.3 or higher.

Hope that helps

这篇关于Struts2的行动未找到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 06:28