14 Replies Latest reply on Jun 22, 2010 3:06 AM by marcuslinke

    JBoss 4.2.1 RemoteEJB Lookup ClassCastException

    kyle.bober

      I have two EAR files that each contain an ejb jar file.
      I have configured each of the EAR files to isolate there classloaders like so..

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jboss-app PUBLIC
       "-//JBoss//DTD J2EE Application 1.4//EN"
       "http://www.jboss.org/j2ee/dtd/jboss-app_4_2.dtd">
      <jboss-app>
       <loader-repository>com.kbss:loader=service1.ear
       <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
       </loader-repository>
      </jboss-app>
      


      and

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jboss-app PUBLIC
       "-//JBoss//DTD J2EE Application 1.4//EN"
       "http://www.jboss.org/j2ee/dtd/jboss-app_4_2.dtd">
      <jboss-app>
       <loader-repository>com.kbss:loader=service2.ear
       <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
       </loader-repository>
      </jboss-app>
      


      Here is the Local, Remote and Implementation class for Service1EJB

      Local
      package com.kbss;
      
      import java.util.List;
      import javax.ejb.Remote;
      
      @Local
      public interface IService1Local {
      
       public static final String EJB_JNDI = "Service1/local";
      
       public Integer read() throws RemoteException;
      }
      


      Remote
      package com.thesearchagency.mms.service.customization;
      
      import java.util.List;
      
      import javax.ejb.Remote;
      import javax.xml.bind.annotation.XmlTransient;
      
      @Remote
      public interface IService1Remote {
      
       /**
       * JNDI registrations for locating interface:
       */
       public static final String EJB_JNDI = "Service1/remote";
      
       public Integer read() throws RemoteException;
      }
      


      Implementation
      
      package com.kbss;
      
      import javax.ejb.Stateless;
      import org.jboss.annotation.ejb.LocalBinding;
      import org.jboss.annotation.ejb.RemoteBinding;
      
      @Stateless
      @LocalBinding(jndiBinding=IService1Local.EJB_JNDI)
      @RemoteBinding(jndiBinding=IService1Remote.EJB_JNDI)
      public class Service1EJB implements IService1Local, IService1Remote {
      
       public Integer read() throws RemoteException {
       return new Integer(123);
       }
      }
      



      Here is the Local, Remote and Implementation class for Service2EJB

      Local
      package com.kbss;
      
      import javax.ejb.Local;
      
      @Local
      public interface IService2Local {
      
       public static final String EJB_JNDI = "Service2/local";
      
       public void test() throws RemoteException;
      }
      


      Remote
      package com.kbss;
      
      import javax.ejb.Remote;
      
      @Remote
      public interface IService2Remote {
      
       public static final String EJB_JNDI = "Service2/remote";
      
      
       public void test() throws RemoteException;
      }
      


      Implementation
      package com.kbss;
      
      import javax.ejb.Stateless;
      import javax.naming.InitialContext;
      import javax.naming.NamingException;
      
      import org.jboss.annotation.ejb.LocalBinding;
      import org.jboss.annotation.ejb.RemoteBinding;
      
      @Stateless
      @LocalBinding(jndiBinding=IUserLocal.EJB_JNDI)
      @RemoteBinding(jndiBinding=IUserRemote.EJB_JNDI)
      public class Service2EJB implements IService2Local, IService2Remote {
      
      
       public void test() throws RemoteException {
      
       InitialContext ctx = new InitialContext();
       IService1Remote remote = (IService1Remote)ctx.lookup(IService1Remote.EJB_JNDI);
       System.out.println("Remote Integer :: "+remote.read());
       }
      }
      


      When I call the test method on service1 I am always presented with the following ClassCastException:
      (I changed some of the above code to remove my clients information so the Exception Stack maybe a little different then the classes stated above)

      javax.ejb.EJBException: java.lang.ClassCastException: $Proxy187
       at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:63)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
       at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:214)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:184)
       at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:81)
       at $Proxy196.create(Unknown Source)
       at com.kbss.mms.service.user.impl.UserWS.create(UserWS.java:48)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.ws.core.server.ServiceEndpointInvokerJSE.invokeServiceEndpointInstance(ServiceEndpointInvokerJSE.java:104)
       at org.jboss.ws.core.server.AbstractServiceEndpointInvoker.invoke(AbstractServiceEndpointInvoker.java:207)
       at org.jboss.ws.core.server.ServiceEndpoint.processRequest(ServiceEndpoint.java:212)
       at org.jboss.ws.core.server.ServiceEndpointManager.processRequest(ServiceEndpointManager.java:448)
       at org.jboss.ws.core.server.AbstractServiceEndpointServlet.doPost(AbstractServiceEndpointServlet.java:114)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
       at org.jboss.ws.core.server.AbstractServiceEndpointServlet.service(AbstractServiceEndpointServlet.java:75)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: java.lang.ClassCastException: $Proxy187
       at com.kbss.mms.service.user.impl.UserEJB.getRemoteService(UserEJB.java:83)
       at com.kbss.mms.service.user.impl.UserEJB.create(UserEJB.java:52)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
       at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
       at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
       ... 48 more
      17:38:07,031 ERROR [SOAPFaultHelperJAXWS] SOAP request exception
      javax.ejb.EJBException: java.lang.ClassCastException: $Proxy187
       at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:63)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
       at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:214)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:184)
       at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:81)
       at $Proxy196.create(Unknown Source)
       at com.kbss.mms.service.user.impl.UserWS.create(UserWS.java:48)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.ws.core.server.ServiceEndpointInvokerJSE.invokeServiceEndpointInstance(ServiceEndpointInvokerJSE.java:104)
       at org.jboss.ws.core.server.AbstractServiceEndpointInvoker.invoke(AbstractServiceEndpointInvoker.java:207)
       at org.jboss.ws.core.server.ServiceEndpoint.processRequest(ServiceEndpoint.java:212)
       at org.jboss.ws.core.server.ServiceEndpointManager.processRequest(ServiceEndpointManager.java:448)
       at org.jboss.ws.core.server.AbstractServiceEndpointServlet.doPost(AbstractServiceEndpointServlet.java:114)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
       at org.jboss.ws.core.server.AbstractServiceEndpointServlet.service(AbstractServiceEndpointServlet.java:75)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: java.lang.ClassCastException: $Proxy187
       at com.kbss.mms.service.user.impl.UserEJB.getRemoteService(UserEJB.java:83)
       at com.thesearchagency.mms.service.user.impl.UserEJB.create(UserEJB.java:52)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
       at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
       at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
       ... 48 more
      
      


      Both of these EAR are deployed on the same JBoss instance. I assume I am doing something wrong in trying to make a RemoteEJB call. Any help here would be much appreciated. I have looked at all the other forum posts in the EJB forum and nothing has helped me resolve this issue.

      Thanks,
      Kyle

        • 1. Re: JBoss 4.2.1 RemoteEJB Lookup ClassCastException
          jaikiran

          What does the jmx-console JNDIView MBean show? Please post that output showing the jndi names and the corresponding objects bound to that name.


          • 2. Re: JBoss 4.2.1 RemoteEJB Lookup ClassCastException
            kyle.bober

            Thanks for the reply jaikiran. Here is the data I got from the JNDIView JMX Console. If you need anything else please let me know and I will happily provide it!

            Thanks again,
            Kyle

            Web Applications
            
            java:comp namespace of the mms-yellsandbox-service-1.0--SNAPSHOT.ear/yellsandboxservice-war-0.0.1-SNAPSHOT.war application:
            
             +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
             +- ORB (class: org.jacorb.orb.ORB)
             +- env (class: org.jnp.interfaces.NamingContext)
             | +- security (class: org.jnp.interfaces.NamingContext)
             | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
             | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)
            
            
            java:comp namespace of the httpha-invoker.sar/invoker.war application:
            
             +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
             +- ORB (class: org.jacorb.orb.ORB)
             +- env (class: org.jnp.interfaces.NamingContext)
             | +- security (class: org.jnp.interfaces.NamingContext)
             | | +- realmMapping[link -> java:/jaas/jmx-console] (class: javax.naming.LinkRef)
             | | +- subject[link -> java:/jaas/jmx-console/subject] (class: javax.naming.LinkRef)
             | | +- securityMgr[link -> java:/jaas/jmx-console] (class: javax.naming.LinkRef)
             | | +- security-domain[link -> java:/jaas/jmx-console] (class: javax.naming.LinkRef)
            
            
            java:comp namespace of the console-mgr.sar/web-console.war application:
            
             +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
             +- ORB (class: org.jacorb.orb.ORB)
             +- env (class: org.jnp.interfaces.NamingContext)
             | +- security (class: org.jnp.interfaces.NamingContext)
             | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
             | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)
            
            
            java:comp namespace of the jmx-console.war application:
            
             +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
             +- ORB (class: org.jacorb.orb.ORB)
             +- env (class: org.jnp.interfaces.NamingContext)
             | +- security (class: org.jnp.interfaces.NamingContext)
             | | +- realmMapping[link -> java:/jaas/jmx-console] (class: javax.naming.LinkRef)
             | | +- subject[link -> java:/jaas/jmx-console/subject] (class: javax.naming.LinkRef)
             | | +- securityMgr[link -> java:/jaas/jmx-console] (class: javax.naming.LinkRef)
             | | +- security-domain[link -> java:/jaas/jmx-console] (class: javax.naming.LinkRef)
            
            
            java:comp namespace of the jbossws.sar/jbossws-context.war application:
            
             +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
             +- ORB (class: org.jacorb.orb.ORB)
             +- env (class: org.jnp.interfaces.NamingContext)
             | +- security (class: org.jnp.interfaces.NamingContext)
             | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
             | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)
            
            
            java:comp namespace of the mms-user-service-1.0--SNAPSHOT.ear/user-service-war-0.0.1-SNAPSHOT.war application:
            
             +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
             +- ORB (class: org.jacorb.orb.ORB)
             +- env (class: org.jnp.interfaces.NamingContext)
             | +- security (class: org.jnp.interfaces.NamingContext)
             | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
             | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)
            
            
            java:comp namespace of the mms-customization-service-1.0--SNAPSHOT.ear/customization-service-war-0.0.1-SNAPSHOT.war application:
            
             +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
             +- ORB (class: org.jacorb.orb.ORB)
             +- env (class: org.jnp.interfaces.NamingContext)
             | +- security (class: org.jnp.interfaces.NamingContext)
             | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
             | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)
            
            
            java:comp namespace of the juddi-service.sar/juddi.war application:
            
             +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
             +- ORB (class: org.jacorb.orb.ORB)
             +- env (class: org.jnp.interfaces.NamingContext)
             | +- jdbc (class: org.jnp.interfaces.NamingContext)
             | | +- juddiDB[link -> java:/DefaultDS] (class: javax.naming.LinkRef)
             | +- security (class: org.jnp.interfaces.NamingContext)
             | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
             | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)
            
            
            java:comp namespace of the jboss-web.deployer/ROOT.war application:
            
             +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
             +- ORB (class: org.jacorb.orb.ORB)
             +- env (class: org.jnp.interfaces.NamingContext)
             | +- security (class: org.jnp.interfaces.NamingContext)
             | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
             | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)
            
            
            java: Namespace
            
             +- ClusteredXAConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
             +- jaas (class: javax.naming.Context)
             | +- messaging (class: org.jboss.security.plugins.SecurityDomainContext)
             | +- JmsXARealm (class: org.jboss.security.plugins.SecurityDomainContext)
             +- TransactionPropagationContextImporter (class: com.arjuna.ats.internal.jbossatx.jta.PropagationContextManager)
             +- comp.ejb3 (class: javax.naming.Context)
             | NonContext: null
             +- JmsXA (class: org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl)
             +- MMSCommonDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
             +- JBossCorbaNaming (class: org.omg.CosNaming.NamingContextExt)
             +- DefaultDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
             +- StdJMSPool (class: org.jboss.jms.asf.StdServerSessionPoolFactory)
             +- TransactionManager (class: com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate)
             +- ClusteredConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
             +- JBossCorbaPOA (class: org.omg.PortableServer.POA)
             +- ConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
             +- TransactionPropagationContextExporter (class: com.arjuna.ats.internal.jbossatx.jta.PropagationContextManager)
             +- DefaultJMSProvider (class: org.jboss.jms.jndi.JNDIProviderAdapter)
             +- XAConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
             +- JBossCorbaInterfaceRepositoryPOA (class: org.omg.PortableServer.POA)
             +- Mail (class: javax.mail.Session)
             +- MMSDemandMapDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
             +- comp.original (class: javax.namingMain.Context)
             +- JBossCorbaORB (class: org.omg.CORBA.ORB)
             +- timedCacheFactory (class: javax.naming.Context)
            Failed to lookup: timedCacheFactory, errmsg=org.jboss.util.TimedCachePolicy
             +- SecurityProxyFactory (class: org.jboss.security.SubjectSecurityProxyFactory)
             +- MMSSiteCustomizationDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
             +- comp (class: javax.naming.Context)
             +- MMSContentRepositoryDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
             +- MMSBizFunctionLocationDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
            
            
            Global JNDI Namespace
            
             +- ClusteredXAConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
             +- HASessionState (class: org.jnp.interfaces.NamingContext)
             | +- Default (class: org.jboss.ha.hasessionstate.server.HASessionStateImpl)
             +- jmx (class: org.jnp.interfaces.NamingContext)
             | +- invoker (class: org.jnp.interfaces.NamingContext)
             | | +- RMIAdaptor (proxy: $Proxy57 implements interface org.jboss.jmx.adaptor.rmi.RMIAdaptor,interface org.jboss.jmx.adaptor.rmi.RMIAdaptorExt)
             | +- rmi (class: org.jnp.interfaces.NamingContext)
             | | +- RMIAdaptor[link -> jmx/invoker/RMIAdaptor] (class: javax.naming.LinkRef)
             +- JAXR (class: org.apache.ws.scout.registry.ConnectionFactoryImpl)
             +- CustomizationService-1.0 (class: org.jnp.interfaces.NamingContext)
             | +- local (proxy: $Proxy116 implements interface com.thesearchagency.mms.service.customization.ICustomizationLocal,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
             | +- remote (proxy: $Proxy114 implements interface com.thesearchagency.mms.service.customization.ICustomizationRemote,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)
             +- ClusteredConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
             +- ConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
             +- UserTransactionSessionFactory (proxy: $Proxy14 implements interface org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory)
             +- XAConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
             +- invokers (class: org.jnp.interfaces.NamingContext)
             | +- pvwb-of1pvd0021 (class: org.jnp.interfaces.NamingContext)
             | | +- iiop (class: org.jboss.invocation.iiop.IIOPInvoker)
             +- TransactionSynchronizationRegistry (class: com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple)
             +- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction)
             +- YellSandboxService-1.0 (class: org.jnp.interfaces.NamingContext)
             | +- local (proxy: $Proxy140 implements interface com.thesearchagency.mms.yellsandbox.IYellSandboxServiceLocal,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
             | +- remote (proxy: $Proxy139 implements interface com.thesearchagency.mms.yellsandbox.IYellSandboxService,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)
             +- HAPartition (class: org.jnp.interfaces.NamingContext)
             | +- kyles-partition (class: org.jboss.ha.framework.server.HAPartitionImpl)
             +- queue (class: org.jnp.interfaces.NamingContext)
             | +- ExpiryQueue (class: org.jboss.jms.destination.JBossQueue)
             | +- testDistributedQueue (class: org.jboss.jms.destination.JBossQueue)
             | +- QueueWithOwnDLQAndExpiryQueue (class: org.jboss.jms.destination.JBossQueue)
             | +- AdMaxServiceRequestQueue (class: org.jboss.jms.destination.JBossQueue)
             | +- SEOsiteGenerationServiceResponseQueue (class: org.jboss.jms.destination.JBossQueue)
             | +- testQueue (class: org.jboss.jms.destination.JBossQueue)
             | +- RefundRequestQueue (class: org.jboss.jms.destination.JBossQueue)
             | +- D (class: org.jboss.jms.destination.JBossQueue)
             | +- PrivateDLQ (class: org.jboss.jms.destination.JBossQueue)
             | +- C (class: org.jboss.jms.destination.JBossQueue)
             | +- B (class: org.jboss.jms.destination.JBossQueue)
             | +- AdMaxRequestQueue (class: org.jboss.jms.destination.JBossQueue)
             | +- A (class: org.jboss.jms.destination.JBossQueue)
             | +- PrivateExpiryQueue (class: org.jboss.jms.destination.JBossQueue)
             | +- DLQ (class: org.jboss.jms.destination.JBossQueue)
             | +- SiteGenerationServiceRequestQueue (class: org.jboss.jms.destination.JBossQueue)
             | +- QueueWithOwnRedeliveryDelay (class: org.jboss.jms.destination.JBossQueue)
             | +- ex (class: org.jboss.jms.destination.JBossQueue)
             | +- SEOsiteGenerationServiceRequestQueue (class: org.jboss.jms.destination.JBossQueue)
             | +- AdMaxResponseQueue (class: org.jboss.jms.destination.JBossQueue)
             | +- SiteGenerationServiceResponseQueue (class: org.jboss.jms.destination.JBossQueue)
             +- topic (class: org.jnp.interfaces.NamingContext)
             | +- testDurableTopic (class: org.jboss.jms.destination.JBossTopic)
             | +- TopicWithOwnRedeliveryDelay (class: org.jboss.jms.destination.JBossTopic)
             | +- testTopic (class: org.jboss.jms.destination.JBossTopic)
             | +- testDistributedTopic (class: org.jboss.jms.destination.JBossTopic)
             | +- TopicWithOwnDLQAndExpiryQueue (class: org.jboss.jms.destination.JBossTopic)
             | +- securedTopic (class: org.jboss.jms.destination.JBossTopic)
             +- console (class: org.jnp.interfaces.NamingContext)
             | +- PluginManager (proxy: $Proxy58 implements interface org.jboss.console.manager.PluginManagerMBean)
             +- HiLoKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGeneratorFactory)
             +- UserService-1.0 (class: org.jnp.interfaces.NamingContext)
             | +- local (proxy: $Proxy124 implements interface com.thesearchagency.mms.service.user.IUserLocal,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
             | +- remote (proxy: $Proxy123 implements interface com.thesearchagency.mms.service.user.IUserRemote,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)
             +- UUIDKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.uuid.UUIDKeyGeneratorFactory)
            
            
            HA-JNDI Namespace
            


            • 3. Re: JBoss 4.2.1 RemoteEJB Lookup ClassCastException
              kyle.bober

              Another piece of information that maybe useful. Here is what the ear-deployer.xml looks like (although I would think that our jboss-app.xml settings override these values on a per EAR basis):

              <?xml version="1.0" encoding="UTF-8"?>
              
              <!-- The JBoss service configuration file for the EAR deployer service.
              $Id: ear-deployer.xml 60679 2007-02-19 21:35:39Z scott.stark@jboss.org $
              -->
              <server>
               <!-- EAR deployer, remove if you are not using ear deployments -->
               <mbean code="org.jboss.deployment.EARDeployer"
               name="jboss.j2ee:service=EARDeployer">
               <!-- A flag indicating if ear deployments should have their own scoped
               class loader to isolate their classes from other deployments.
               -->
               <attribute name="Isolated">false</attribute>
               <!-- A flag indicating if the ear components should have in VM call
               optimization disabled.
               -->
               <attribute name="CallByValue">false</attribute>
               <!-- A flag the enables the default behavior of the ee5 library-directory. If true,
               the lib contents of an ear are assumed to be the default value for library-directory
               in the absence of an explicit library-directory. If false, there must be an
               explicit library-directory.
               -->
               <attribute name="EnablelibDirectoryByDefault">true</attribute>
               </mbean>
              </server>


              • 4. Re: JBoss 4.2.1 RemoteEJB Lookup ClassCastException
                jaikiran

                 

                "kyle.bober" wrote:
                I have two EAR files that each contain an ejb jar file.
                I have configured each of the EAR files to isolate there classloaders like so..


                So you have 2 EARs each isolated. And then you have the EJB3 beans and the @Service deployed through one ear and the @Service is being accessed through the other? And you have the interfaces of the @Service beans packaged in both the isolated EARs?

                • 5. Re: JBoss 4.2.1 RemoteEJB Lookup ClassCastException
                  kyle.bober

                  Yes, that is correct. What do you mean by @Service? Am I missing and annotation?

                  • 6. Re: JBoss 4.2.1 RemoteEJB Lookup ClassCastException
                    kyle.bober

                    FYI: The JNDI names for the two services I am trying to access are

                    CustomizationService-1.0
                    UserService-1.0

                    I had changed my code sample due to this being my client's code.

                    • 7. Re: JBoss 4.2.1 RemoteEJB Lookup ClassCastException
                      kyle.bober

                      UserService-1.0 is making a remote call to CustomizationService-1.0

                      • 8. Re: JBoss 4.2.1 RemoteEJB Lookup ClassCastException
                        jaikiran

                         

                        "kyle.bober" wrote:
                        What do you mean by @Service? Am I missing and annotation?


                        Ah, forget that @Service thing. I just mixed up another thread and also got confused by the interface names you had for those stateless beans.

                        The important thing i was interested in knowing was :

                        "jaikiran" wrote:
                        And you have the interfaces of the beans packaged in both the isolated EARs?


                        Which you answered:

                        "kyle.bober" wrote:
                        Yes, that is correct.


                        So from what i see, this looks similar to EJBTHREE-1889 which we'll be fixing.
                        From what i have seen in that issue, i guess you do have a workaround for @Stateless beans. Instead of looking up the bean, try injecting it:
                        @Stateless
                        @LocalBinding(jndiBinding=IUserLocal.EJB_JNDI)
                        @RemoteBinding(jndiBinding=IUserRemote.EJB_JNDI)
                        public class Service2EJB implements IService2Local, IService2Remote {
                        
                        @EJB (mappedName=IService1Remote.EJB_JNDI)
                        IService1Remote anotherBean;
                        
                         public void test() throws RemoteException {
                         System.out.println("Remote Integer :: "+anotherBean.read());
                         }






                        • 9. Re: JBoss 4.2.1 RemoteEJB Lookup ClassCastException
                          jaikiran

                          P.S: I just noticed you are using 4.2.1 AS, so i am not really sure if that bug and the workaround applies to your case. Probably it does.

                          • 10. Re: JBoss 4.2.1 RemoteEJB Lookup ClassCastException
                            kyle.bober

                            So I modified my code as you stated by injecting the RemoteEJB interface using @EJB like so:

                            @EJB(mappedName=ICustomizationRemote.EJB_JNDI)
                            ICustomizationRemote theCustomizationService;
                            


                            I now see the following exception.

                            com.thesearchagency.mms.service.user.UserException: Non matching type for inject of field: com.thesearchagency.mms.service.customization.ICustomizationRemote com.thesearchagency.mms.service.user.impl.UserEJB.theCustomizationService for type: $Proxy164 of jndiName env/com.thesearchagency.mms.service.user.impl.UserEJB/theCustomizationService
                            intfs: , com.thesearchagency.mms.service.customization.ICustomizationRemote, org.jboss.ejb3.JBossProxy, javax.ejb.EJBObject; nested exception is:
                             java.lang.RuntimeException: Non matching type for inject of field: com.thesearchagency.mms.service.customization.ICustomizationRemote com.thesearchagency.mms.service.user.impl.UserEJB.theCustomizationService for type: $Proxy164 of jndiName env/com.thesearchagency.mms.service.user.impl.UserEJB/theCustomizationService
                            intfs: , com.thesearchagency.mms.service.customization.ICustomizationRemote, org.jboss.ejb3.JBossProxy, javax.ejb.EJBObject
                             at com.thesearchagency.mms.service.user.impl.UserWS.login(UserWS.java:36)
                             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                             at java.lang.reflect.Method.invoke(Method.java:585)
                             at org.jboss.ws.core.server.ServiceEndpointInvokerJSE.invokeServiceEndpointInstance(ServiceEndpointInvokerJSE.java:104)
                             at org.jboss.ws.core.server.AbstractServiceEndpointInvoker.invoke(AbstractServiceEndpointInvoker.java:207)
                             at org.jboss.ws.core.server.ServiceEndpoint.processRequest(ServiceEndpoint.java:212)
                             at org.jboss.ws.core.server.ServiceEndpointManager.processRequest(ServiceEndpointManager.java:448)
                             at org.jboss.ws.core.server.AbstractServiceEndpointServlet.doPost(AbstractServiceEndpointServlet.java:114)
                             at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
                             at org.jboss.ws.core.server.AbstractServiceEndpointServlet.service(AbstractServiceEndpointServlet.java:75)
                             at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
                             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                             at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                             at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
                             at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                             at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
                             at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                             at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
                             at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
                             at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
                             at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                             at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
                             at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                             at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
                             at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                             at java.lang.Thread.run(Thread.java:595)
                            Caused by: java.lang.RuntimeException: Non matching type for inject of field: com.thesearchagency.mms.service.customization.ICustomizationRemote com.thesearchagency.mms.service.user.impl.UserEJB.theCustomizationService for type: $Proxy164 of jndiName env/com.thesearchagency.mms.service.user.impl.UserEJB/theCustomizationService
                            intfs: , com.thesearchagency.mms.service.customization.ICustomizationRemote, org.jboss.ejb3.JBossProxy, javax.ejb.EJBObject
                             at org.jboss.injection.JndiFieldInjector.inject(JndiFieldInjector.java:127)
                             at org.jboss.injection.JndiFieldInjector.inject(JndiFieldInjector.java:105)
                             at org.jboss.injection.JndiFieldInjector.inject(JndiFieldInjector.java:62)
                             at org.jboss.ejb3.AbstractPool.create(AbstractPool.java:111)
                             at org.jboss.ejb3.ThreadlocalPool.get(ThreadlocalPool.java:61)
                             at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:54)
                             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                             at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
                             at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
                             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                             at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
                             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                             at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
                             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                             at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:278)
                             at org.jboss.ejb3.remoting.IsLocalInterceptor.invokeLocal(IsLocalInterceptor.java:79)
                             at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:70)
                             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                             at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:103)
                             at $Proxy178.login(Unknown Source)
                             at com.thesearchagency.mms.service.user.impl.UserWS.login(UserWS.java:27)
                             ... 30 more
                            Caused by: java.lang.IllegalArgumentException
                             at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
                             at java.lang.reflect.Field.set(Field.java:656)
                             at org.jboss.injection.JndiFieldInjector.inject(JndiFieldInjector.java:115)
                             ... 50 more


                            Which is a much better sign then the ClassCastException :) What exactly does the mappedName parameter refer too?

                            I have the following in my EJB Implementation class:

                            @Stateless
                            @LocalBinding(jndiBinding=ICustomizationLocal.EJB_JNDI)
                            @RemoteBinding(jndiBinding=ICustomizationRemote.EJB_JNDI)
                            @Interceptors(SpringBeanAutowiringInterceptor.class)
                            @XmlTransient
                            public class CustomizationEJB implements ICustomizationLocal, ICustomizationRemote {
                            



                            • 11. Re: JBoss 4.2.1 RemoteEJB Lookup ClassCastException
                              kyle.bober

                              Okay so I added the following code to inject the remote EJB instance like so

                              @EJB(mappedName=ICustomizationRemote.EJB_JNDI)
                              ICustomizationRemote theCustomizationService;
                              


                              I know run into the following exception

                              com.thesearchagency.mms.service.user.UserException: Non matching type for inject of field: com.thesearchagency.mms.service.customization.ICustomizationRemote com.thesearchagency.mms.service.user.impl.UserEJB.theCustomizationService for type: $Proxy220 of jndiName env/com.thesearchagency.mms.service.user.impl.UserEJB/theCustomizationService
                              intfs: , com.thesearchagency.mms.service.customization.ICustomizationRemote, org.jboss.ejb3.JBossProxy, javax.ejb.EJBObject; nested exception is:
                               java.lang.RuntimeException: Non matching type for inject of field: com.thesearchagency.mms.service.customization.ICustomizationRemote com.thesearchagency.mms.service.user.impl.UserEJB.theCustomizationService for type: $Proxy220 of jndiName env/com.thesearchagency.mms.service.user.impl.UserEJB/theCustomizationService
                              intfs: , com.thesearchagency.mms.service.customization.ICustomizationRemote, org.jboss.ejb3.JBossProxy, javax.ejb.EJBObject
                               at com.thesearchagency.mms.service.user.impl.UserWS.login(UserWS.java:36)
                               at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                               at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                               at java.lang.reflect.Method.invoke(Method.java:585)
                               at org.jboss.ws.core.server.ServiceEndpointInvokerJSE.invokeServiceEndpointInstance(ServiceEndpointInvokerJSE.java:104)
                               at org.jboss.ws.core.server.AbstractServiceEndpointInvoker.invoke(AbstractServiceEndpointInvoker.java:207)
                               at org.jboss.ws.core.server.ServiceEndpoint.processRequest(ServiceEndpoint.java:212)
                               at org.jboss.ws.core.server.ServiceEndpointManager.processRequest(ServiceEndpointManager.java:448)
                               at org.jboss.ws.core.server.AbstractServiceEndpointServlet.doPost(AbstractServiceEndpointServlet.java:114)
                               at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
                               at org.jboss.ws.core.server.AbstractServiceEndpointServlet.service(AbstractServiceEndpointServlet.java:75)
                               at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
                               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                               at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                               at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
                               at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                               at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
                               at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                               at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
                               at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
                               at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
                               at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                               at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
                               at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                               at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
                               at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                               at java.lang.Thread.run(Thread.java:595)
                              Caused by: java.lang.RuntimeException: Non matching type for inject of field: com.thesearchagency.mms.service.customization.ICustomizationRemote com.thesearchagency.mms.service.user.impl.UserEJB.theCustomizationService for type: $Proxy220 of jndiName env/com.thesearchagency.mms.service.user.impl.UserEJB/theCustomizationService
                              intfs: , com.thesearchagency.mms.service.customization.ICustomizationRemote, org.jboss.ejb3.JBossProxy, javax.ejb.EJBObject
                               at org.jboss.injection.JndiFieldInjector.inject(JndiFieldInjector.java:127)
                               at org.jboss.injection.JndiFieldInjector.inject(JndiFieldInjector.java:105)
                               at org.jboss.injection.JndiFieldInjector.inject(JndiFieldInjector.java:62)
                               at org.jboss.ejb3.AbstractPool.create(AbstractPool.java:111)
                               at org.jboss.ejb3.ThreadlocalPool.get(ThreadlocalPool.java:61)
                               at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:54)
                               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                               at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
                               at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
                               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                               at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
                               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                               at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
                               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                               at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:278)
                               at org.jboss.ejb3.remoting.IsLocalInterceptor.invokeLocal(IsLocalInterceptor.java:79)
                               at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:70)
                               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                               at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:103)
                               at $Proxy234.login(Unknown Source)
                               at com.thesearchagency.mms.service.user.impl.UserWS.login(UserWS.java:27)
                               ... 30 more
                              Caused by: java.lang.IllegalArgumentException
                               at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
                               at java.lang.reflect.Field.set(Field.java:656)
                               at org.jboss.injection.JndiFieldInjector.inject(JndiFieldInjector.java:115)
                               ... 50 more
                              


                              This is what my EJB Implementation class looks like

                              @Stateless
                              @LocalBinding(jndiBinding=ICustomizationLocal.EJB_JNDI)
                              @RemoteBinding(jndiBinding=ICustomizationRemote.EJB_JNDI)
                              @Interceptors(SpringBeanAutowiringInterceptor.class)
                              @XmlTransient
                              public class CustomizationEJB implements ICustomizationLocal, ICustomizationRemote {... }
                              


                              I am curious are my LocalBinding and RemoteBinding correct? does the jndiBinding parameter in those two annotations relate to the @EJB mappedParameter?

                              @EJB(mappedName=ICustomizationRemote.EJB_JNDI)

                              Also if this is a bug is there any way to patch it in a JBoss 4.2.1.GA environment?

                              Thanks again,
                              Kyle

                              • 12. Re: JBoss 4.2.1 RemoteEJB Lookup ClassCastException
                                kyle.bober

                                So I am assuming this is a bug in JBoss 4.2.1 and Remote EJB calls from a client are not possible... ?

                                • 13. Re: JBoss 4.2.1 RemoteEJB Lookup ClassCastException
                                  jaikiran

                                   

                                  com.thesearchagency.mms.service.user.UserException: Non matching type for inject of field: com.these
                                  archagency.mms.service.customization.ICustomizationRemote com.thesearchagency.mms.service.user.impl.
                                  UserEJB.theCustomizationService for type: $Proxy220 of jndiName env/com.thesearchagency.mms.service.
                                  user.impl.UserEJB/theCustomizationService
                                  intfs: , com.thesearchagency.mms.service.customization.ICustomizationRemote, org.jboss.ejb3.JBossPro
                                  xy, javax.ejb.EJBObject; nested exception is:
                                  java.lang.RuntimeException: Non matching type for inject of field: com.thesearchagency.mms.service.
                                  customization.ICustomizationRemote com.thesearchagency.mms.service.user.impl.UserEJB.theCustomizatio
                                  nService for type: $Proxy220 of jndiName env/com.thesearchagency.mms.service.user.impl.UserEJB/theCu
                                  stomizationService
                                  intfs: , com.thesearchagency.mms.service.customization.ICustomizationRemote, org.jboss.ejb3.JBossPro
                                  xy, javax.ejb.EJBObject


                                  As suspected, it's the similar to what we fixed as part of EJBTHREE-1889 for AS-5.

                                  Also if this is a bug is there any way to patch it in a JBoss 4.2.1.GA environment?

                                  The 4.x community branch is way too old and is no longer being developed. The code too is vastly different from the current state. The possible options are:

                                  1) Upgrade to latest 5.1.0 AS and you start using the EJB3 plugins
                                  2) Checkout AS 4.x branch from source and then you will have to manually create the patch and build the AS.
                                  3) If you have a support contract with the enterprise edition of AS (the EAP version), you can always file a ticket and the issue will be fixed in the enterprise edition branch and will be made available to you.

                                  So I am assuming this is a bug in JBoss 4.2.1 and Remote EJB calls from a client are not possible... ?

                                  Remote calls are possible. The problem you are running into is that you have isolated your deployments and are packaging the EJB interfaces in each deployment (a valid case, btw). The proxy being bound is JNDI uses a different classloader (corresponding to deployment A) and the injection/lookup happens using a different classloader (corresponding to deployment B) and hence the classcast exception.


                                  • 14. Re: JBoss 4.2.1 RemoteEJB Lookup ClassCastException
                                    marcuslinke

                                    I've read this and found a simpler solution / workaround for this problem (without the need of patching). It's simple to integrate the appropriate code taken from EJBTHREE-1889 into the own JNDI lookup. Because of performance reasons this hack of course should be used only for JVM internal remote lookups (which is the case with isolated EAR's). This may be realized by using different JNDI lookup wrapper classes...

                                     

                                    public class JBossRemoteJndiLookup<T> {

                                        public T lookup(String resourceName) {
                                            Object o = new InitialContext().lookup(resourceName);
                                            o = refineObjectInContextClassLoader(o);
                                            return (T) o;
                                        }

                                     

                                        /**
                                         * This is a workaround for http://community.jboss.org/thread/111016. It is taken from
                                         * https://jira.jboss.org/browse/EJBTHREE-1889. See modifications of ProxyObjectFactory.java
                                         */
                                        private Object refineObjectInContextClassLoader(Object o) {
                                            // EJBTHREE-1889: if the lookup has been performed locally on a remote (business)
                                            // interface that's defined in the current TCL, then the proxy must implement
                                            // that TCL defined interface.
                                            // redefine in TCL
                                            ClassLoader tcl = Thread.currentThread().getContextClassLoader();
                                            try {
                                                o = redefineObjectInClassLoader(o, tcl);
                                            } catch (Exception e) {
                                                throw new RuntimeException(e);
                                            }
                                            return o;
                                        }

                                     

                                        private Object redefineObjectInClassLoader(Object obj, ClassLoader target) throws ClassNotFoundException,
                                                IOException {
                                            ByteArrayOutputStream bout = new ByteArrayOutputStream();
                                            ObjectOutputStream out = new ObjectOutputStream(bout);
                                            out.writeObject(obj);
                                            out.flush();
                                            ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
                                            ObjectInputStream in = new ObjectInputStreamWithClassLoader(bin, target);
                                            Object result = in.readObject();
                                            in.close();
                                            return result;
                                        }

                                    }