9 Replies Latest reply on Sep 22, 2010 5:44 AM by wdfink

    How to call remote EJB in Jboss 4.2.x from Jboss 6

    paradigmza

      Hi

       

      I am testing JBoss 6, and I am having difficulty calling a remote EJB in JBoss 4.

       

      I create a very simple Servlet (deployed as a war file) that calls the remote EJB from JBoss 6.

       

       

           Properties environment = new Properties();
           environment.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
           environment.put(Context.URL_PKG_PREFIXES, "org.jboss.namingrg.jnp.interfaces");
           environment.put(Context.PROVIDER_URL, "jnp://172.16.38.203:1099");
           InitialContext context = new InitialContext(environment);
           ServiceInstructionRemote serviceLookup = (ServiceInstructionRemote) context.lookup("pocit/ServicesInstructionEJB/remote");
           result = serviceLookup.callService(new ServiceRequestBean(), true);
      

       

       

      Properties environment = new Properties();
              environment.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
              environment.put(Context.URL_PKG_PREFIXES, "org.jboss.namingrg.jnp.interfaces");
              environment.put(Context.PROVIDER_URL, "jnp://172.16.38.203:1099");
              InitialContext context = new InitialContext(environment);
              ServiceInstructionRemote serviceLookup = (ServiceInstructionRemote) context.lookup("pocit/ServicesInstructionEJB/remote");
              result = serviceLookup.callService(new ServiceRequestBean(), true);

       

      Now I can do this easily with a standard java application client (j2se) (or from another Jboss 4.2.3. I just include the proper jboss-client jars and do as above and it works perfectly.

       

      But for jboss 6 when i include the jboss client jars of jboss 4.2.3 I get funny errors

       

      Caused by: java.lang.RuntimeException: Error visiting resource: org.jboss.classloading.plugins.vfs.VFSResourceContext@6de17d0b, visitor: org.jboss.scanning.annotations.plugins.GenericAnnotationVisitor@31873729
      at org.jboss.scanning.plugins.visitor.IgnoreSetErrorHandler.handleError(IgnoreSetErrorHandler.java:57) [:1.0.0.Alpha5]
      at org.jboss.scanning.plugins.visitor.ReflectResourceVisitor.visit(ReflectResourceVisitor.java:91) [:1.0.0.Alpha5]
      at org.jboss.scanning.annotations.plugins.AnnotationsScanningPlugin.visit(AnnotationsScanningPlugin.java:89) [:1.0.0.Alpha5]
      at org.jboss.scanning.spi.helpers.ScanningPluginWrapper.visit(ScanningPluginWrapper.java:112) [:1.0.0.Alpha5]
      at org.jboss.classloading.plugins.visitor.FederatedResourceVisitor.visit(FederatedResourceVisitor.java:101) [jboss-classloading.jar:2.2.0.Alpha7]
      at org.jboss.classloading.plugins.vfs.VFSResourceVisitor.visit(VFSResourceVisitor.java:264) [jboss-classloading-vfs.jar:2.2.0.Alpha7]
      ... 53 more
      Caused by: java.lang.VerifyError: (class: org/jboss/ejb3/stateless/StatelessRemoteProxyFactory, method: getInterfaces signature: ()[Ljava/lang/Class;) Incompatible argument to function
      

       

       

      And if I don't include any JBoss 4 client jars I get the standard RMI error  (I don't want to setup RMI security for this, I should not need to dynamically download any classes). (ps... i did get this working by setting up a security manager and just including the jboss 4 aspect jar, but that is not the point)

       

      Okay, my question. How do i call a EJB in a old jboss from JBoss 6 (m4)?  (ie which jars do i need to include in my war)

       

      Thanks,

      Sean.

        • 1. Re: How to call remote EJB in Jboss 4.2.x from Jboss 6
          ngoodman310

          I think you should be able to use the standard Java interfaces instead of the JBoss ones in the jboss client jar.

          • 2. Re: How to call remote EJB in Jboss 4.2.x from Jboss 6
            wdfink

            Hi,

            I have a long painfull expirience with this (JBoss5.1 call JBoss4.3 application).

            The result was to deploy both applications within the same server.

             

            The might use IIOP instead of RMI this will decouple the two JBoss server.

            Connect with => "corbaloc:iiop:wfink1-jb1:3528/JBoss/Naming/root"

            But you must reconfigure the target application (no RMI available).

             

            The final killer was that the transaction context is not propagated, the transaction is a different one. So a rollback at JB6 will not rollback the JB4 transaction because it is commited.

            • 3. Re: How to call remote EJB in Jboss 4.2.x from Jboss 6
              jaikiran

              EJBs invocations between AS 4.x and AS 6.x isn't expected to work.

              • 4. Re: How to call remote EJB in Jboss 4.2.x from Jboss 6
                paradigmza

                ? That is confusing. JBoss 6/5/4 can invoke ejb's on glassfish, websphere, Geronimo, etc... by just including the correct client. Is this not a major short coming? (as there are plenty of JBoss 4 servers out here).

                • 5. Re: How to call remote EJB in Jboss 4.2.x from Jboss 6
                  wdfink

                  Remember that JBoss knows JBoss classes and you are in trouble with the Classloader, nevertheless that you are deploying the JBoss4 all-client.jar in your EAR.

                  • 6. Re: How to call remote EJB in Jboss 4.2.x from Jboss 6
                    paradigmza

                    Yes, I understand that fully. But you would think that there would be a simple solution to this problem (communication between its own products). I can get the above working like this 

                     

                    JBoss 6 Servlet -> Glassfish  EJB -> Jboss 4 EJB

                     

                    but not...

                     

                    Jboss 6 Servlet -> Jboss 4 EJB.

                     

                    Do you not think that is just absurd?

                    • 7. Re: How to call remote EJB in Jboss 4.2.x from Jboss 6
                      wdfink

                      Indeed, but I think you will have the same trouble with other AppServer ;-(

                      • 8. Re: How to call remote EJB in Jboss 4.2.x from Jboss 6
                        zinabnm

                        Hi it seems I have the same issue. I have to call remote EJB 3 session bean but in my case EJB 3 session bean is deployed on JBoss 5.1 and it is invoked from JBoss 4.2.3GA server. Invocation is wrapped in JAR lib with all JBoss 5.1 client libs (client libs are repacked). The lib is in /jboss-4.2.3.GA/server/all/deploy/lib. When I call session bean on JBoss 5.1 I got:

                         

                         

                         

                        010-09-21 16:35:01,132 DEBUG [org.jboss.ejb3.proxy.impl.objectfactory.ProxyObjectFactory] org.jboss.ejb3.proxy.impl.objectfactory.ProxyObjectFactory servicing request for AdServiceGate
                        2010-09-21 16:35:01,188 DEBUG [org.jboss.remoting.transport.socket.MicroSocketClientInvoker] SocketClientInvoker[18b1699, socket://AZINCHENKO-WS1:3873] constructed
                        2010-09-21 16:35:01,189 DEBUG [org.jboss.remoting.MicroRemoteClientInvoker] SocketClientInvoker[18b1699, socket://AZINCHENKO-WS1:3873] connecting
                        2010-09-21 16:35:01,189 DEBUG [org.jboss.remoting.transport.socket.MicroSocketClientInvoker] Creating semaphore with size 50
                        2010-09-21 16:35:01,189 DEBUG [org.jboss.remoting.MicroRemoteClientInvoker] SocketClientInvoker[18b1699, socket://AZINCHENKO-WS1:3873] connected
                        2010-09-21 16:35:01,374 DEBUG [org.jboss.remoting.transport.socket.ClientSocketWrapper] reset timeout: 0
                        2010-09-21 16:35:01,631 DEBUG [org.jboss.remoting.InvokerRegistry] removed SocketClientInvoker[18b1699, socket://AZINCHENKO-WS1:3873] from registry
                        2010-09-21 16:35:01,631 DEBUG [org.jboss.remoting.transport.socket.MicroSocketClientInvoker] SocketClientInvoker[18b1699, socket://AZINCHENKO-WS1:3873] disconnecting ...
                        2010-09-21 16:35:01,632 DEBUG [org.jboss.remoting.transport.socket.SocketWrapper] ClientSocketWrapper[Socket[addr=/192.168.20.82,port=3873,localport=54601].1ef0b44] closing
                        2010-09-21 16:35:01,632 DEBUG [org.jboss.ejb3.proxy.impl.objectfactory.session.SessionProxyObjectFactory] Created Proxy of type $Proxy97 for EJB3 Business Interface: com.webvoice.advertizing.common.sbt.ServiceGate
                        2010-09-21 16:35:01,638 DEBUG [org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase] Couldn't handle invocation directly within org.jboss.ejb3.proxy.impl.handler.session.SessionRemoteProxyInvocationHandler@175beef: Current invocation "public abstract java.lang.Object com.webvoice.advertizing.common.sbt.ServiceGate.invokeMethodByHash(java.lang.String,java.lang.Object[]) throws java.lang.Throwable" is not eligible for direct handling by org.jboss.ejb3.proxy.impl.handler.session.SessionRemoteProxyInvocationHandler@175beef
                        2010-09-21 16:35:01,686 DEBUG [com.arjuna.ats.internal.jbossatx.jta.PropagationContextManager] PropagationContextManager.getTransactionPropagationContext - called
                        2010-09-21 16:35:01,687 DEBUG [org.jboss.remoting.transport.socket.MicroSocketClientInvoker] SocketClientInvoker[10bfedd, socket://AZINCHENKO-WS1:3873] constructed
                        2010-09-21 16:35:01,687 DEBUG [org.jboss.remoting.MicroRemoteClientInvoker] SocketClientInvoker[10bfedd, socket://AZINCHENKO-WS1:3873] connecting
                        2010-09-21 16:35:01,687 DEBUG [org.jboss.remoting.transport.socket.MicroSocketClientInvoker] Creating semaphore with size 50
                        2010-09-21 16:35:01,687 DEBUG [org.jboss.remoting.MicroRemoteClientInvoker] SocketClientInvoker[10bfedd, socket://AZINCHENKO-WS1:3873] connected
                        2010-09-21 16:35:01,841 DEBUG [org.jboss.remoting.transport.socket.ClientSocketWrapper] reset timeout: 0
                        2010-09-21 16:35:01,892 DEBUG [org.jboss.remoting.InvokerRegistry] removed SocketClientInvoker[10bfedd, socket://AZINCHENKO-WS1:3873] from registry
                        2010-09-21 16:35:01,892 DEBUG [org.jboss.remoting.transport.socket.MicroSocketClientInvoker] SocketClientInvoker[10bfedd, socket://AZINCHENKO-WS1:3873] disconnecting ...
                        2010-09-21 16:35:01,892 DEBUG [org.jboss.remoting.transport.socket.SocketWrapper] ClientSocketWrapper[Socket[addr=/192.168.20.82,port=3873,localport=54602].dad6d0] closing
                        2010-09-21 16:35:01,896 INFO  [STDOUT] java.lang.IllegalStateException: Unexpected server exception: java.lang.NullPointerException
                            at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:379)
                            at org.jboss.ejb3.session.InvokableContextClassProxyHack._dynamicInvoke(InvokableContextClassProxyHack.java:53)
                            at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:91)
                        

                         

                         

                        As I can see I found my remote object (Created Proxy of type $Proxy97 for EJB3 Business Interface: com.webvoice.advertizing.common.sbt.ServiceGate) and invoke method on it and then got this(2010-09-21 16:35:01,638 DEBUG [org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase] Couldn't handle invocation directly within org.jboss.ejb3.proxy.impl.handler.session.SessionRemoteProxyInvocationHandler@175beef: Current invocation "public abstract java.lang.Object com.webvoice.advertizing.common.sbt.ServiceGate.invokeMethodByHash(java.lang.String,java.lang.Object[]) throws java.lang.Throwable" is not eligible for direct handling by org.jboss.ejb3.proxy.impl.handler.session.SessionRemoteProxyInvocationHandler@175beef)

                         

                        So I can test my lib from standalone application - it successfully invoke EJB 3 session bean is deployed on JBoss 5.1

                        I guess the problem is in client libs conflict. I tryed to put JBoss 5.1 client libs in /jboss-4.2.3.GA/server/all/deploy/lib (in the same dir as my lib is) and point my lib to them by specifying Class-Path attribute in manifest file for my JAR - without result.

                         

                        Now I am looking in http://community.jboss.org/wiki/JBossClassLoadingUseCases but without optimism, after a lot of time spending with the problem. All I found in internet do not contain solution and common advice is to put all under the same version of JBoss. But I can not. So it will be possible to do one thing - direct Socket

                        • 9. Re: How to call remote EJB in Jboss 4.2.x from Jboss 6
                          wdfink

                          Hi,

                          for me I decide to avoid such cross-calling ...

                           

                          In your case I think it might help if you attach the jboss-client stuff into you EAR file with a separate classloader.

                          This should work until you will have transaction accross the two jboss instances (here I found no solution)