4 Replies Latest reply on Jul 20, 2012 10:56 AM by maverik87

    EJB3 arguments by reference

    maverik87 Newbie

      Hi all,

       

      In JBoss 7.1.1, is it possible to pass arguments by reference between two stateless local session beans?

       

      Thanks!

        • 2. Re: EJB3 arguments by reference
          maverik87 Newbie

          Thanks for the answer, it confirms my opinion about arguments passing between local SB. But, if arguments passing between local SB is by reference, why arguments have to be serializable? JBoss 7.1.1 gives me following exceptions:

           

          org.apache.jasper.JasperException: javax.ejb.EJBException: java.lang.RuntimeException: IOException marshaling EJB parameters

                  org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:413)

                  org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:326)

                  org.apache.jasper.servlet.JspServlet.service(JspServlet.java:253)

                  javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

           

          root cause


          javax.ejb.EJBException: java.lang.RuntimeException: IOException marshaling EJB parameters
               org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:166)
               org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:230)
               org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304)
               org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190)
               org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
               org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
               org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
               org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59)
               org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
               org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
               org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
               org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:32)
               org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
               org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)
               org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
               org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
               org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165)
               org.jboss.as.ejb3.remote.LocalEjbReceiver.processInvocation(LocalEjbReceiver.java:179)
               org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:179)
               org.jboss.ejb.client.TransactionInterceptor.handleInvocation(TransactionInterceptor.java:43)
               org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)
               org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:128)
               org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)
               org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136)
               org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121)
               org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)
               $Proxy68.findCloseExcursions(Unknown Source)
               org.apache.jsp.index_jsp._jspService(index_jsp.java:179)
               org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
               javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
               org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
               org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:326)
               org.apache.jasper.servlet.JspServlet.service(JspServlet.java:253)
               javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

          root cause


          java.lang.RuntimeException: IOException marshaling EJB parameters
               org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:227)
               org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:216)
               org.jboss.as.ejb3.remote.LocalEjbReceiver.processInvocation(LocalEjbReceiver.java:133)
               org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:179)
               org.jboss.ejb.client.TransactionInterceptor.handleInvocation(TransactionInterceptor.java:43)
               org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)
               org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:128)
               org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)
               org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136)
               org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121)
               org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)
               $Proxy71.loadCacheWithGivenExcursions(Unknown Source)
               it.trekker.prefetch.ExcursionDAOWithPrefetch.findCloseExcursions(ExcursionDAOWithPrefetch.java:151)
               sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
               sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
               sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
               java.lang.reflect.Method.invoke(Method.java:597)
               org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72)
               org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
               org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
               org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36)
               org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
               org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47)
               org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
               org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)
               org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
               org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
               org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53)
               org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
               org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51)
               org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
               org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:228)
               org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304)
               org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190)
               org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
               org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
               org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
               org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59)
               org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
               org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
               org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
               org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:32)
               org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
               org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)
               org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
               org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
               org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165)
               org.jboss.as.ejb3.remote.LocalEjbReceiver.processInvocation(LocalEjbReceiver.java:179)
               org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:179)
               org.jboss.ejb.client.TransactionInterceptor.handleInvocation(TransactionInterceptor.java:43)
               org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)
               org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:128)
               org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)
               org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136)
               org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121)
               org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)
               $Proxy68.findCloseExcursions(Unknown Source)
               org.apache.jsp.index_jsp._jspService(index_jsp.java:179)
               org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
               javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
               org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
               org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:326)
               org.apache.jasper.servlet.JspServlet.service(JspServlet.java:253)
               javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

          root cause


          java.io.NotSerializableException: it.trekker.prefetch.ExcursionsCache
               org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:256)
               org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:135)
               org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:225)
               org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:216)
               org.jboss.as.ejb3.remote.LocalEjbReceiver.processInvocation(LocalEjbReceiver.java:133)
               org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:179)
               org.jboss.ejb.client.TransactionInterceptor.handleInvocation(TransactionInterceptor.java:43)
               org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)
               org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:128)
               org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)
               org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136)
               org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121)
               org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)
               $Proxy71.loadCacheWithGivenExcursions(Unknown Source)
               it.trekker.prefetch.ExcursionDAOWithPrefetch.findCloseExcursions(ExcursionDAOWithPrefetch.java:151)
               sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
               sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
               sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
               java.lang.reflect.Method.invoke(Method.java:597)
               org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72)
               org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
               org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
               org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36)
               org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
               org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47)
               org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
               org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)
               org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
               org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
               org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53)
               org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
               org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51)
               org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
               org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:228)
               org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304)
               org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190)
               org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
               org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
               org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
               org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59)
               org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
               org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
               org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
               org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:32)
               org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
               org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)
               org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
               org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
               org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165)
               org.jboss.as.ejb3.remote.LocalEjbReceiver.processInvocation(LocalEjbReceiver.java:179)
               org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:179)
               org.jboss.ejb.client.TransactionInterceptor.handleInvocation(TransactionInterceptor.java:43)
               org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)
               org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:128)
               org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)
               org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136)
               org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121)
               org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)
               $Proxy68.findCloseExcursions(Unknown Source)
               org.apache.jsp.index_jsp._jspService(index_jsp.java:179)
               org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
               javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
               org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
               org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:326)
               org.apache.jasper.servlet.JspServlet.service(JspServlet.java:253)
               javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

           

          and my source is:

           

          @Stateful

          @Local(IExcursionDAOWithPrefetch.class)

          public class ExcursionDAOWithPrefetch implements IExcursionDAOWithPrefetch {

           

               @Resource

               SessionContext ctx;

           

               @EJB(lookup="ejb:TrekkerServer/TrekkerServer.jar/EJB3ExcursionDAO!it.trekker.dao.IExcursionDAO")

               IExcursionDAO excursionDAO;

               @EJB(lookup="ejb:TrekkerServer/TrekkerServer.jar/CacheLoader!it.trekker.prefetch.ICacheLoader")

               ICacheLoader cacheLoader;

           

               private ExcursionsCache cache;

           

               ...

           

           

               public Excursion findExcursionById(int id, boolean loadCoordinates) {

                    // Retrieve from cache

                    Excursion excursion = cache.getExcursionById(id);

           

                    if(excursion == null) {

                         logger.info("excursion " + id + " not in cache: retrieving it from database");

           

                         // Retrieve from database

                         excursion = excursionDAO.findExcursionById(id, loadCoordinates);

                         centerOfTheSearch = excursion.getStartPoint();

           

                         cache.invalidateCache();

                         cacheLoader.loadCacheWithCloseExcursions(cache, excursion, SEARCHING_RADIUS/2);

                    }

                    else {

                         logger.info("excursion " + id + " in cache");

           

                         if(GPSCoordinate.distanceBetween(centerOfTheSearch, excursion.getStartPoint()) > SEARCHING_RADIUS/2) {

                              cache.invalidateCache();

                              cacheLoader.loadCacheWithCloseExcursions(cache, excursion, SEARCHING_RADIUS/2);

                         }

                    }

           

                    logger.info("end findExcursionById");

           

                     return excursion;

               }

           

               ...

          }

           

          CacheLoader class is:

           

          @Stateless
          @Local(ICacheLoader.class)
          @Asynchronous
          public class CacheLoader implements ICacheLoader {
               ...

               public void loadCacheWithCloseExcursions(ExcursionsCache cache, Excursion excursion, double radius) {
                    ...
               }

               public void loadCacheWithGivenExcursions(ExcursionsCache cache, List<Excursion> excursionList) {
                    ...
               }
          }
          • 3. Re: EJB3 arguments by reference
            jaikiran pai Master

            It's a bug which was fixed recently https://issues.jboss.org/browse/AS7-5103 and is available in the nightly build https://community.jboss.org/thread/167590. The bug is actually triggered by the wrong JNDI name that you are using for the injection/lookup. Take a look at the JIRA comments for details on how to fix it in your code.

            1 of 1 people found this helpful
            • 4. Re: EJB3 arguments by reference
              maverik87 Newbie

              Great! You have solved my problem, thank you very much!!!!