2012-12-31 201 views
2

我正在將我的應用程序服務器從Jboss 4.2遷移到7.1。我在Struts配置中遇到以下錯誤。在struts.xml中定義的操作正在調用,Action程序包中的操作未被調用。我也發佈我的Actionstruts.xml和堆棧跟蹤。Struts2未找到操作錯誤

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

更新到2.3.4的Struts後:

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] 
+0

@SkipValidation批註可能非常有用,而不是定義允許從驗證中排除某些方法的自定義攔截器堆棧。 –

+0

BTW'com.lntinfotech.virtuoso.web.action.DttjoinAction'沒有在配置中提及。而noclassdeffound exceprion意味着這個動作不存在,並且你的配置錯誤。 –

+0

com.lntinfotech.virtuoso.web.action是包含我所有Action類的Action Package。 xwork-core 2.3.4無法識別導致Action未定義錯誤的Action類。任何方案? –

回答

1

我認爲這個問題可能來自於你在同一個命名空間有兩個包。嘗試刪除一個包,或更改其中之一的命名空間(也許是第一個,也就是空)


編輯:

這是Bug WW-3662: (Struts2) convention-plugin not work in jboss-7.0.0

正如你可以看到,它在最新版本中得到解決。

因此,如果您需要遷移到JBoss 7,您需要遷移到Struts 2.3.3或更高版本。

希望幫助

+0

不,我試圖通過刪除默認包以及更改默認包的命名空間都dint工作:( –

+0

是的,我將我的struts版本升級到2.3.4,之後,我得到的類未定義error.I更新問題與新的堆棧跟蹤 –

+1

現在可能是由於同一個庫的多個版本在您的項目上...仔細檢查它 –

1

使用@Namespace("/")爲您的操作。並使用@Action(value = "loginValidate",以便您可以從動作映射中找到您的操作。如果仍然沒有幫助嘗試刪除

<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" /> 

編輯:

如果使用Convention插件,爲什麼你有在struts.xml中包。從XML中刪除所有重複的配置。使用@ParentPackage("default")

<constant name="struts.convention.default.parent.package" value="default"/> 
+0

我試過所有的建議力量工作.. –

+0

@Kabilan看到我的編輯,並嘗試這種建議。 –

+0

ur solutions dint工作。反正謝謝你提出一些答案.. –

0

關注羅馬C'S指令和下面的行添加到您的struts.xml

<constant name="struts.convention.package.locators.basePackage" value="com.infotech.project.web.action"/> 

我建議使用的配置,瀏覽器插件,以確保您調用之前註釋的行動成功加載他們。