5 Replies Latest reply on Dec 3, 2010 6:50 PM by zeppelinux

    Remote EJB call fails from JBossAS 6 to JBossAS 5. Bug?

    zeppelinux

      Hi,

       

      I'm trying to call some remote EJB deployed on JBossAS 5.0.1.GA from Weld bean deployed on JBossAS 6.0.0.20101110-CR1 "Neo" and it fails with the NPE.

       

      The remote reference looks to be obtained from JNDI and I can see the interface created, but when any method is called it fails with:

       

      Caused by: java.lang.NullPointerException at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:185)
      at $Proxy244.findByRefId(Unknown Source)
      at tu.controller.Integrator.callMethod(Integrator.java:21)
      at tu.controller.org$jboss$weld$bean-jboss$classloader:id="vfs:$$$C:$dev$workspace$WeldRichFacesPOC$target$WeldRichFacesPOC$war"-ManagedBean-class_tu$controller$Integrator_$$_WeldClientProxy.callMethod(org$jboss$weld$bean-jboss$classloader:id="vfs:$$$C:$dev$workspace$WeldRichFacesPOC$target$WeldRichFacesPOC$war"-ManagedBean-class_tu$controller$Integrator_$$_WeldClientProxy.java)
      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:597)
      at org.apache.el.parser.AstValue.invoke(AstValue.java:196)
      at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
      at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:43)
      at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:72)
      at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:43)
      at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:72)
      at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:102)
      at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:84)

       

       

      The same EJB invoked remotely from JBossAS5 works correctly.

       

      Is JBossAS 6 is not compatible with JbossAS 5 EJB's or its is a bug?

        • 1. Re: Remote EJB call fails from JBossAS 6 to JBossAS 5. Bug?
          jaikiran

          Can you post a bit more details including the code of the EJBs involved?

           

          By the way, it's better to upgrade to 5.1.0 of JBoss AS and apply the EJB3 plugin http://www.jboss.org/ejb3/ejb3plugin.html over it. There has been numerous bug fixes and performance improvements after 5.0.1 was released.

          • 2. Re: Remote EJB call fails from JBossAS 6 to JBossAS 5. Bug?
            zeppelinux

            Hi Jaikiran, Thanks for Your reply!

             

            I'v applied the patch, didn't helped... here is the Weld component :

             

            @Model
            public class JBoss6Component {

             

               @Inject
               private Logger log;

             

               public void callMethod(){
                   JBoss5EJB manager = (JBoss5EJB)JNDILookup.lookup(JBoss5EJB.REMOTE_NAME);

                    // the manager stub is returned from JNDILookup
                   String result = manager.testCall();  // here is fails with NPE
                   log.info("testCall() result: + " + result);
               }
            }

             

            as you see it invokes the JBoss5EJB deployed on JBoss 5 server, here are the details :

             

            @Remote
            public interface JBoss5EJB {

             

                public static final String REMOTE_NAME = "customer/test/JBoss5EJB";

             

                public String testCall();

             

            }

             

            @Stateless
            @RemoteBinding(jndiBinding= JBoss5EJB.REMOTE_NAME)
            public class JBoss5EJBImpl implements JBoss5EJB {

             

                @Override
                public String testCall() {
                    return "ok";
                }
            }

             

            We can't upgrade our servers to 5.1.0 right now.

             

            I can provide any other info.

             

            Thanks,

            Dmitry.

            • 3. Re: Remote EJB call fails from JBossAS 6 to JBossAS 5. Bug?
              zeppelinux

              just for test installed the JBossAS 5.1.0 server and the same code throws different error:

               

              javax.naming.NamingException: Could not dereference object [Root exception is java.lang.RuntimeException: Exception while trying to locate proxy factory in JNDI, at key ProxyFactory/customer/JBoss5EJBImpl/customer/test/JBoss5EJB]
                   at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1508)
                  at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:824)
                  at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:688)
                  at javax.naming.InitialContext.lookup(InitialContext.java:392)
                   at tu.venture.common.jndi.util.JNDILookup.lookup(JNDILookup.java:37)
                   at tu.venture.common.jndi.util.JNDILookup.lookup(JNDILookup.java:51)
                  at tu.controller.JBoss6Component.callMethod(JBoss6Component.java:21)

               

              So it creates wrong JNDI name (key) now.

               

              Please note, the exact same code (and JNDI lookup method) used to obtain the stub and invoke some method and it behaves totally different against 5.0.1 and 5.1.0 servers...  to me it looks like a big fat BUG, should I submit report?

              • 4. Re: Remote EJB call fails from JBossAS 6 to JBossAS 5. Bug?
                wolfc

                Remote EJB calls between major versions of AS are not supported.

                 

                If you want you can use the construct I outlined in my blog.

                http://wolf-71.blogspot.com/2010/02/et-phone-home.html

                • 5. Re: Remote EJB call fails from JBossAS 6 to JBossAS 5. Bug?
                  zeppelinux

                  Tried your solutions and it stil fails, now with ClassNotFoundException for JBoss5EJB.

                   

                  Not sure, but it looks like because it runs in total isolation from all application classes it can't find anything except of explicitly specified jbossall-client.jar.

                   

                  Should I specify all my jars (and their dependencies jars) the same way as jbossall-client.jar - as a parameters to the custom URLClassLoader?

                   

                  Here is and exception:

                   

                  12:56:56,192 ERROR [STDERR] Caused by: java.lang.ClassNotFoundException: tu.venture.customer.api.service.JBoss5EJB
                  12:56:56,192 ERROR [STDERR]     at org.jboss.remoting.serialization.ClassLoaderUtility.loadClass(ClassLoaderUtility.java:103)
                  12:56:56,192 ERROR [STDERR]     at org.jboss.remoting.loading.RemotingClassLoader.loadClass(RemotingClassLoader.java:86)
                  12:56:56,192 ERROR [STDERR]     at java.lang.Class.forName0(Native Method)
                  12:56:56,192 ERROR [STDERR]     at java.lang.Class.forName(Class.java:247)
                  12:56:56,192 ERROR [STDERR]     at org.jboss.remoting.loading.ObjectInputStreamWithClassLoader.resolveProxyClass(ObjectInputStreamWithClassLoader.java:253)
                  12:56:56,192 ERROR [STDERR]     at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1531)
                  12:56:56,192 ERROR [STDERR]     at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1493)
                  12:56:56,192 ERROR [STDERR]     at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
                  12:56:56,192 ERROR [STDERR]     at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
                  12:56:56,192 ERROR [STDERR]     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
                  12:56:56,192 ERROR [STDERR]     at org.jboss.aop.joinpoint.InvocationResponse.readExternal(InvocationResponse.java:119)
                  12:56:56,192 ERROR [STDERR]     at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1792)
                  12:56:56,192 ERROR [STDERR]     at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1751)
                  12:56:56,192 ERROR [STDERR]     at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
                  12:56:56,192 ERROR [STDERR]     at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
                  12:56:56,192 ERROR [STDERR]     at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
                  12:56:56,192 ERROR [STDERR]     at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
                  12:56:56,192 ERROR [STDERR]     at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
                  12:56:56,192 ERROR [STDERR]     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
                  12:56:56,192 ERROR [STDERR]     at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObjectVersion2_2(JavaSerializationManager.java:238)
                  12:56:56,192 ERROR [STDERR]     at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObject(JavaSerializationManager.java:138)
                  12:56:56,192 ERROR [STDERR]     at org.jboss.remoting.marshal.serializable.SerializableUnMarshaller.read(SerializableUnMarshaller.java:123)
                  12:56:56,192 ERROR [STDERR]     at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.versionedRead(MicroSocketClientInvoker.java:1220)
                  12:56:56,192 ERROR [STDERR]     at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.transport(MicroSocketClientInvoker.java:850)
                  12:56:56,192 ERROR [STDERR]     at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:165)
                  12:56:56,192 ERROR [STDERR]     at org.jboss.remoting.Client.invoke(Client.java:1724)
                  12:56:56,192 ERROR [STDERR]     at org.jboss.remoting.Client.invoke(Client.java:629)
                  12:56:56,192 ERROR [STDERR]     at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:60)
                  12:56:56,192 ERROR [STDERR]     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
                  12:56:56,192 ERROR [STDERR]     at org.jboss.ejb3.proxy.impl.remoting.IsLocalProxyFactoryInterceptor.invoke(IsLocalProxyFactoryInterceptor.java:72)
                  12:56:56,192 ERROR [STDERR]     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
                  12:56:56,192 ERROR [STDERR]     at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:62)
                  12:56:56,207 ERROR [STDERR]     at $Proxy242.createProxyBusiness(Unknown Source)
                  12:56:56,207 ERROR [STDERR]     at org.jboss.ejb3.proxy.impl.objectfactory.session.SessionProxyObjectFactory.createProxy(SessionProxyObjectFactory.java:129)
                  12:56:56,207 ERROR [STDERR]     at org.jboss.ejb3.proxy.impl.objectfactory.session.stateless.StatelessSessionProxyObjectFactory.getProxy(StatelessSessionProxyObjectFactory.java:79)
                  12:56:56,207 ERROR [STDERR]     at org.jboss.ejb3.proxy.impl.objectfactory.ProxyObjectFactory.getObjectInstance(ProxyObjectFactory.java:158)
                  12:56:56,207 ERROR [STDERR]     at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
                  12:56:56,207 ERROR [STDERR]     at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1479)
                  12:56:56,207 ERROR [STDERR]     at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1496)
                  12:56:56,207 ERROR [STDERR]     at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:822)
                  12:56:56,207 ERROR [STDERR]     at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
                  12:56:56,207 ERROR [STDERR]     at javax.naming.InitialContext.lookup(InitialContext.java:392)
                  12:56:56,207 ERROR [STDERR]     at tu.controller.JBoss6Component.callMethod(JBoss6Component.java:60)

                   

                  #################################################################

                   

                  Update: Altough it looks like a perfectly designed nighmare to deploy and maintain, I decided to give it a shot and included the jar with JBoss5EJB interface into the classpath for the custom URLClassLoader, but unfortunately it still fails (ClassCastException for now) on this line:

                   

                  JBoss5EJB bean = (JBoss5EJB)context.lookup(JBoss5EJB.REMOTE_NAME);

                   

                  Caused by: java.lang.ClassCastException: $Proxy244 cannot be cast to tu.venture.customer.api.service.JBoss5EJB

                  at tu.controller.JBoss6Component.callMethod(JBoss6Component.java:63)

                   

                  Is there anything else I can try to make the basic EJB3 call working between two JBoss servers? I'm totally stuck now