4 Replies Latest reply on May 25, 2013 4:11 PM by larshe

    Seam 2.3 migration - lookup of Session Beans from asynchronous call

    larshe

      I am having a problem with jndi lookups of Session Beans from asynchronous calls ( via Component.getInstance(...) ) in Seam 2.3. Lookup of POJO components is working fine. The calls are initiated by the quartz scheduler declared as:


      <async:quartz-dispatcher/>.
      
      <event type="org.jboss.seam.postInitialization">        <action execute="#{quartzController.scheduleTimer}"/>
      </event>
      
      



      As per the migration guide in the Seam 2.3 documentation I have changed the lookup pattern in web.xml to :

      <core:init jndi-pattern="java:app/aubama-ejb/#{ejbName}"/>

       

      I also have declared:
      <component class="org.jboss.seam.transaction.EjbSynchronizations" jndi-name="java:app/jboss-seam/EjbSynchronizations"/>
      

       

      Example:

      Name("garpSyncWrapper")public class GarpSyncWrapper {
          @Asynchronous
          public void synchronize(@IntervalCron String cronString) {
              syncSuppliers();
          }
          public void syncSuppliers() {
              // Lookup of a SLSB
              SupplierSynchronizer supplierSynchronizer = (SupplierSynchronizer) Component.getInstance("supplierSynchronizer");
             ...
          }
      
      }
      

       

      The supplierSynchronizer lookup above fails when asynchronously called via synchronize(...) method above. If called synchronously from the web-gui the lookup succeeds. The cause of the failure when called asynchronously is:

      ----------------------------

      Exception thrown whilst executing asynchronous call: org.jboss.seam.InstantiationException: Could not instantiate Seam component: supplierSynchronizer

      ...

      Caused by: javax.naming.NameNotFoundException: java:app/aubama-ejb/SupplierSynchronizerBean

      ----------------------------

       

       

      Lookup also fails when Seam initiates an asynchronous lookup of EjbSynchronizations which I think is a stateful session bean (Same here, no lookup error when called synchronously). Exception:

      ----------------------------

      Exception thrown whilst executing asynchronous call: org.jboss.seam.InstantiationException: Could not instantiate Seam component: org.jboss.seam.transaction.synchronizations

      ...

      Caused by: javax.naming.NameNotFoundException: java:app/jboss-seam/EjbSynchronizations

      -----------------------------

       

       

      This code worked fine in Seam 2.2. Any ideas what I might be doing wrong or if this is a bug of some kind?

      Thanks.

        • 1. Re: Seam 2.3 migration - lookup of Session Beans from asynchronous call
          gadeyne.bram

          I'm having the same issue.

           

          Did you manage to work around this problem?

          • 2. Re: Seam 2.3 migration - lookup of Session Beans from asynchronous call
            larshe

            Yes, I solved it by changing the lookup from java:app/ to the remote namespace java:global/ instead.

            I don't see why that should be needed really in this case but it has worked for me without any side effects I'm aware of.  

            • 3. Re: Seam 2.3 migration - lookup of Session Beans from asynchronous call
              ibenjes

              Hi Lars,

               

              can you post what exactly you have changed? I've tried it and it doesn't seem to work for me.

               

              At start up I get the message:

               

              15:33:58,534 INFO  [][EjbJndiBindingsDeploymentUnitProcessor] (MSC s) JNDI bindings for session bean named EjbSynchronizations in deployment unit subdeployment "jboss-seam.jar" of deployment "MyApp.ear" are as follows:

               

               

                        java:global/MyApp/jboss-seam/EjbSynchronizations!org.jboss.seam.transaction.LocalEjbSynchronizations

                        java:app/jboss-seam/EjbSynchronizations!org.jboss.seam.transaction.LocalEjbSynchronizations

                        java:module/EjbSynchronizations!org.jboss.seam.transaction.LocalEjbSynchronizations

                        java:global/MyApp/jboss-seam/EjbSynchronizations

                        java:app/jboss-seam/EjbSynchronizations

                        java:module/EjbSynchronizations

               

              I've tried

              <component class="org.jboss.seam.transaction.EjbSynchronizations" jndi-name="java:app/jboss-seam/EjbSynchronizations"/>

              and

              <component class="org.jboss.seam.transaction.EjbSynchronizations" jndi-name="java:global/MyApp/jboss-seam/EjbSynchronizations"/>

               

              in component.xml but I still get

              Caused by: javax.naming.NameNotFoundException:  java:global/MyApp/jboss-seam/EjbSynchronizations

               

              Did you change the core:init jndi-pattern as well?

              • 4. Re: Seam 2.3 migration - lookup of Session Beans from asynchronous call
                larshe

                Immo, my settings are:

                 

                component.xml:

                <core:init jndi-pattern="@jndiPattern@" debug="true" distributable="@distributable@"/>

                <component class="org.jboss.seam.transaction.EjbSynchronizations" jndi-name="java:global/aubama/jboss-seam/EjbSynchronizations"/>

                   

                pom.xml:

                <properties>

                        <jndiPattern>java:global/aubama/aubama-ejb/#{ejbName}</jndiPattern>

                        <distributable>false</distributable>

                </properties>

                 

                /Lars