0

环境:

  • WildFly-9.0.2.Final
  • Struts 2.2.1
  • 蚂蚁

我正在从单独的 struts2.2.1 应用程序中查找本地 EJB3 无状态 bean。

包含无状态 EJB3的 JAR ( testcommon.jar ) 和包含WEB-INF/lib上带有 struts2.2.1 应用程序的 WAR的 EAR ( test.ear )分别部署在同一个 WildFly-9.0.2 上.终审。

testcommon.jar的部署日志如下。

14:04:22,157 INFO  [org.jboss.weld.deployer] (MSC service thread 1-2) WFLYWELD0010: Stopping weld service for deployment testcommon.jar
14:04:22,165 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) WFLYSRV0028: Stopped deployment testcommon.jar (runtime-name: testcommon.jar) in 18ms
14:04:22,175 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) WFLYSRV0027: Starting deployment of "testcommon.jar" (runtime-name: "testcommon.jar")
14:04:22,189 INFO  [org.jboss.weld.deployer] (MSC service thread 1-1) WFLYWELD0003: Processing weld deployment testcommon.jar
14:04:22,202 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-1) JNDI bindings for session bean named TestHelperBean in deployment unit deployment "testcommon.jar" are as follows:

java:global/testcommon/TestHelperBean!interfacehelper.ejb3.jar.TestHelperLocal
java:app/testcommon/TestHelperBean!interfacehelper.ejb3.jar.TestHelperLocal
java:module/TestHelperBean!interfacehelper.ejb3.jar.TestHelperLocal
java:global/testcommon/TestHelperBean
java:app/testcommon/TestHelperBean
java:module/TestHelperBean

14:04:22,215 INFO  [org.jboss.weld.deployer] (MSC service thread 1-1) WFLYWELD0006: Starting Services for CDI deployment: testcommon.jar
14:04:22,224 INFO  [org.jboss.weld.deployer] (MSC service thread 1-4) WFLYWELD0009: Starting weld service for deployment testcommon.jar
14:04:22,566 INFO  [org.jboss.as.server] (XNIO-1 task-2) WFLYSRV0016: Replaced deployment "testcommon.jar" with deployment "testcommon.jar"

用action类编写的Java代码(存在于test.ear中)如下

package test.common.struts;

import interfacehelper.ejb3.jar.TestHelperLocal;
import javax.naming.InitialContext;
import com.opensymphony.xwork2.ActionSupport;

public class TestAction extends ActionSupport {

    public String struts2Core221_wildfly902Final() throws Exception {
        System.out.println(" Struts2-core-2.2.1 testing with Wildfly 9.0.2.Final-- going to lookup" +
            " Ejb3 stateless session bean present in testcommon.jar ");
        ((TestHelperLocal) getTestHelperBeanLocal()).ejb3StatelessSessionInJar();
        return "forwardToJsp";
    }

    private TestHelperLocal getTestHelperBeanLocal() throws Exception {
        try {
            return (TestHelperLocal) new InitialContext().lookup("java:global/testcommon/TestHelperBean!interfacehelper.ejb3.jar.TestHelperLocal");
        } catch(Exception e) {
            e.printStackTrace();
            throw e;
        }
    }
}

在访问test.ear中存在的操作类时,出现以下错误:

10:26:37,428 INFO  [stdout] (default task-3)  Struts2-core-2.2.1 testing with Wildfly 9.0.2.Final-- going to lookup Ejb3 stateless session bean present in jar 
10:26:37,431 ERROR [stderr] (default task-3) java.lang.ClassCastException: interfacehelper.ejb3.jar.TestHelperLocal$$$view2 cannot be cast to interfacehelper.ejb3.jar.TestHelperLocal
10:26:37,432 ERROR [stderr] (default task-3)    at test.common.struts.TestAction.getTestHelperBeanLocal(TestAction.java:18)
10:26:37,432 ERROR [stderr] (default task-3)    at test.common.struts.TestAction.struts2Core221_wildfly902Final(TestAction.java:11)
10:26:37,433 ERROR [stderr] (default task-3)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
10:26:37,434 ERROR [stderr] (default task-3)    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
10:26:37,434 ERROR [stderr] (default task-3)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
10:26:37,434 ERROR [stderr] (default task-3)    at java.lang.reflect.Method.invoke(Method.java:497)
10:26:37,434 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
10:26:37,434 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
10:26:37,436 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)
10:26:37,436 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
10:26:37,437 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
10:26:37,438 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
10:26:37,438 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
10:26:37,438 ERROR [stderr] (default task-3)    at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
10:26:37,438 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
10:26:37,438 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
10:26:37,443 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)
10:26:37,449 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
10:26:37,451 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
10:26:37,451 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
10:26:37,452 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
10:26:37,452 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
10:26:37,452 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
10:26:37,463 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
10:26:37,463 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
10:26:37,463 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
10:26:37,464 ERROR [stderr] (default task-3)    at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
10:26:37,464 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
10:26:37,464 ERROR [stderr] (default task-3)    at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
10:26:37,464 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
10:26:37,464 ERROR [stderr] (default task-3)    at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
10:26:37,464 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
10:26:37,464 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
10:26:37,464 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
10:26:37,464 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
10:26:37,464 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
10:26:37,465 ERROR [stderr] (default task-3)    at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
10:26:37,465 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
10:26:37,465 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:142)
10:26:37,465 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
10:26:37,465 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:166)
10:26:37,465 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
10:26:37,465 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
10:26:37,465 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
10:26:37,465 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
10:26:37,466 ERROR [stderr] (default task-3)    at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
10:26:37,466 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
10:26:37,466 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
10:26:37,466 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
10:26:37,466 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
10:26:37,466 ERROR [stderr] (default task-3)    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
10:26:37,466 ERROR [stderr] (default task-3)    at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
10:26:37,466 ERROR [stderr] (default task-3)    at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:485)
10:26:37,466 ERROR [stderr] (default task-3)    at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
10:26:37,467 ERROR [stderr] (default task-3)    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
10:26:37,474 ERROR [stderr] (default task-3)    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
10:26:37,475 ERROR [stderr] (default task-3)    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)
10:26:37,475 ERROR [stderr] (default task-3)    at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85)
10:26:37,475 ERROR [stderr] (default task-3)    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
10:26:37,475 ERROR [stderr] (default task-3)    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
10:26:37,475 ERROR [stderr] (default task-3)    at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
10:26:37,476 ERROR [stderr] (default task-3)    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
10:26:37,476 ERROR [stderr] (default task-3)    at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
10:26:37,476 ERROR [stderr] (default task-3)    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
10:26:37,476 ERROR [stderr] (default task-3)    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
10:26:37,476 ERROR [stderr] (default task-3)    at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
10:26:37,476 ERROR [stderr] (default task-3)    at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
10:26:37,476 ERROR [stderr] (default task-3)    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58)
10:26:37,476 ERROR [stderr] (default task-3)    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:72)
10:26:37,477 ERROR [stderr] (default task-3)    at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
10:26:37,477 ERROR [stderr] (default task-3)    at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)
10:26:37,479 ERROR [stderr] (default task-3)    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
10:26:37,479 ERROR [stderr] (default task-3)    at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
10:26:37,479 ERROR [stderr] (default task-3)    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
10:26:37,479 ERROR [stderr] (default task-3)    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
10:26:37,479 ERROR [stderr] (default task-3)    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:282)
10:26:37,480 ERROR [stderr] (default task-3)    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:261)
10:26:37,480 ERROR [stderr] (default task-3)    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:80)
10:26:37,480 ERROR [stderr] (default task-3)    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:172)
10:26:37,480 ERROR [stderr] (default task-3)    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:199)
10:26:37,480 ERROR [stderr] (default task-3)    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:774)
10:26:37,480 ERROR [stderr] (default task-3)    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
10:26:37,480 ERROR [stderr] (default task-3)    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
10:26:37,482 ERROR [stderr] (default task-3)    at java.lang.Thread.run(Thread.java:745)

为什么会出现这个错误?

4

0 回答 0