4 Replies Latest reply on Jun 7, 2013 2:21 AM by wdfink

    Jboss 6.1.0.alpha - how to handle Asynchronous proxy using ejb2.1

    georgesg

      I am currently in the process of migrating from Jboss 4.3.GA to Jboss EAP 6.1.0.alpha.  The below piece of code we used for Jboss 4.3.GA.  In Jboss 6.1.0 our applications don't need any proxy or RMI call using client or rmi API projects, Since all the deployments are deployed and invoked locally in the Application Server.

       

      In this case , how i can get the Asynchrous behavior asper the Jboss 6 EAP specifications for local lookups ?

       

       

      Code Snippets:

       

      QueueManagerLocal createBean =

                          (QueueManagerLocal)ctx.lookup(LocalBeanNames.QUEUE_MANAGER_LOCAL_BEAN);

                 

                  QueueManagerLocal asyncCreate =

                          (QueueManagerLocal) Asynch.getAsynchronousProxy(createBean);

       

       

      Where, QUEUE_MANAGER_LOCAL_BEAN = "java:global/TSM/QueueManagerEjb-1.0.0-SNAPSHOT/QueueManagerBean!com.cassis.queue.manager.service.QueueManagerLocal";

        • 1. Re: Jboss 6.1.0.alpha - how to handle Asynchronous proxy using ejb2.1
          georgesg

          The problem is that,  I am getting the below exception.

           

          Caused by: java.lang.ClassCastException: com.cassis.queue.manager.service.QueueManagerLocal$$$view10 cannot be cast to org.jboss.ejb3.JBossProxy

                  at org.jboss.ejb3.asynchronous.Asynch.getAsynchronousProxy(Asynch.java:38) [jbossall-client-4.2.2.GA.jar:4.2.2.GA (build: SVNTag=JBoss_4_2_2_GA date=200710221139)]

                  at com.cassis.queue.manager.process.QueueProcess.queueRequestAsync(QueueProcess.java:125) [QueueManagerEjb-1.0.0-SNAPSHOT.jar:]

                  ... 95 more

           

           

           

          Code snippet from jbossall-client-4.2.2.GA.jar :

           

          package org.jboss.ejb3.asynchronous;

           

          import org.jboss.aspects.asynch.AsynchProvider;

          import org.jboss.aspects.asynch.Future;

          import org.jboss.ejb3.JBossProxy;

           

          public class Asynch

          {

            public static Object getAsynchronousProxy(Object ejbRef)

            {

              JBossProxy proxy = (JBossProxy)ejbRef;

              return proxy.getAsynchronousProxy();

            }

           

            public static Future getFutureResult(Object asynchProxy)

            {

              AsynchProvider provider = (AsynchProvider)asynchProxy;

              return provider.getFuture();

            }

          }

          • 2. Re: Jboss 6.1.0.alpha - how to handle Asynchronous proxy using ejb2.1
            wdfink

            Are you mixing the client library of AS4 with the EAP6?

            • 3. Re: Jboss 6.1.0.alpha - how to handle Asynchronous proxy using ejb2.1
              georgesg

              yes. Basically the client library is packaged as a part of the EAR Binary. So , the application picksup from EAR /Lib directory.

               

              When i read the documents about Asynchronous proxy, understood that when we pass any ejbref as a parameter, it will be returned as an Asynchronous ejbref. But in this case, why this class cast excception is happening ? Any idea ?

              • 4. Re: Jboss 6.1.0.alpha - how to handle Asynchronous proxy using ejb2.1
                wdfink

                You can not deploy a application packed with incompatible JBoss classes. If the classes are used you will have such CCE.

                 

                Your approach looks like not supported from the EJB2 spec. In EAP6 the class is not available as the code is rewritten with AS7.

                 

                I think the solution for your problem is to migrate the bean to EJB3 and use the asynchronous invocation which is part of this spec.