0

Environment:

  • WildFly-9.0.2.Final
  • Struts 2.2.1
  • ANT

I am looking up a local EJB3 stateless bean from a separate struts2.2.1 application.

The JAR (testcommon.jar), which contains the stateless EJB3, and the EAR (test.ear), which contains a WAR with struts2.2.1 application on WEB-INF/lib, are separately deployed on the same WildFly-9.0.2.Final instance.

Deployment logs for testcommon.jar are as follows.

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"

Java code written in action class(present in test.ear) is as follows

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

While accessing the action class, present in test.ear, following error has been occurring:

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)

Why this errror has been occurred?

António Ribeiro
  • 4,129
  • 5
  • 32
  • 49
user595014
  • 114
  • 3
  • 8
  • 20
  • 1
    That's the only error information you get? Nothing more on the stack trace? – António Ribeiro May 04 '16 at 21:36
  • @aribeiro...I have edited with complete stack-trace. – user595014 May 05 '16 at 05:23
  • 1
    Honestly I can't think of any reason why the CCE is occurring. Unless it as something to do with the way you're packaging your application. Is there any specific reason for you to deploy your JAR separately? If the WAR depends on it, why not drop the EAR and keep only the WAR, with the JAR on the WAR's lib folder? – António Ribeiro May 05 '16 at 20:31
  • @aribeiro...Sir,When i anotate TestHelperLocal class to '@Remote' instead of '@Local',than application is working fine, But same scenario was working fine in JBss 5.x(using '@LocalBinding'(jndiBinding="JNDI") &'@Local' anotation), should i have to anotate with '@Remote' in this scenario? Is there any complement for '@LocalBinding' anotation in wildfly? Would i not be able to use '@Local' anotation,if dependency is cross application? – user595014 May 06 '16 at 05:00
  • 1
    Well, as mentioned [here](http://stackoverflow.com/a/36024731/1346996), starting on JBoss AS 7, JBoss no longer supports binding to custom JNDI names for EJBs. Therefore, yes, you should make use of `@Remote`. For further information, I'd advise you to take a look at [WildFly's JNDI Reference documentation](https://docs.jboss.org/author/display/WFLY9/JNDI+Reference). Also, you could think about dropping the `InitialCntext.lookup` and replace it by a `@EJB`, that allows the injection of your bean instance. – António Ribeiro May 06 '16 at 06:59

0 Answers0