3 Replies Latest reply on Feb 1, 2011 5:52 PM by Jean Luc

    entityManager is sometimes null

    Shawn Zimmerman Newbie

      I am periodically receiving the following error in my application, however it may be a different component every-time:


      Caused by javax.servlet.ServletException with message: "#{serviceTableBean.getOrders}: org.jboss.seam.RequiredException: @In attribute requires non-null value: serviceTableBean.entityManager"



      I can re-create this issue!  The application has a series of Richfaces tabs, each of which contain datatables.  When a tab is clicked, the tab contents are refreshed (simply refreshing stale datatables).  If I click on a tab, and without waiting for the ajax request to finish, click on another tab, the entityManager is null (error above) on the tab refresh that was in process.  However, if I am patient and wait for all ajax to finish, it works without issue.  It seems to be a timing/concurrent type of issue.


      What could be causing this?  How can I fix it?


      Here is my components.xml:


      <persistence:entity-manager-factory name="entityManagerFactory" persistence-unit-name="productPU" />
      <persistence:managed-persistence-context name="entityManager" auto-create="true" entity-manager-factory="#{entityManagerFactory}" />
      <factory name="session" scope="STATELESS" auto-create="true" value="#{entityManager.delegate}" />
      



      I am using Seam 2.2.0GA, Glassfish 2.1.1 and Richfaces 3.3.3Final.


      Shawn

        • 1. Re: entityManager is sometimes null
          Jean Luc Apprentice

          Any other error in the log that would have prevented the entityManager to be injected (such as the transaction being already marked for rollback?).


          Check if the size of the db connection pool is enough.


          Load test the app, perhaps you'll be able to reproduce it.


          • 2. Re: entityManager is sometimes null
            Shawn Zimmerman Newbie

            Looking in the logs, I found some more details higher up:


            [#|2011-02-01T14:57:31.187-0500|WARNING|sun-appserver2.1|org.jboss.seam.jsf.SeamPhaseListener|_ThreadID=18;_ThreadName=httpSSLWorkerThread-443-3;_RequestID=e8a834a6-db60-4cd5-8373-b5772ea9eeb8;|uncaught exception, passing to exception handler
            org.jboss.seam.ConcurrentRequestTimeoutException: Concurrent call to conversation



            [#|2011-02-01T14:57:31.218-0500|SEVERE|sun-appserver2.1|org.jboss.seam.jsf.SeamPhaseListener|_ThreadID=18;_ThreadName=httpSSLWorkerThread-443-3;_RequestID=e8a834a6-db60-4cd5-8373-b5772ea9eeb8;|swallowing exception
            org.jboss.seam.ConcurrentRequestTimeoutException: Concurrent call to conversation



            [#|2011-02-01T14:57:31.218-0500|WARNING|sun-appserver2.1|org.jboss.seam.Component|_ThreadID=18;_ThreadName=httpSSLWorkerThread-443-3;_RequestID=e8a834a6-db60-4cd5-8373-b5772ea9eeb8;|
            Cannot create Seam component, scope is not active: entityManager(CONVERSATION)|#]



            After further research, I used an eventsQueue on the rich:tab tag and it appears to have resolved the issue!  I am not sure the actual reason of the cuncurrenty.  Is it a good habit to queue all ajax requests?


            Thanks.  Shawn

            • 3. Re: entityManager is sometimes null
              Jean Luc Apprentice

              Shawn Zimmerman wrote on Feb 01, 2011 15:58:

              After further research, I used an eventsQueue on the rich:tab tag and it appears to have resolved the issue!  I am not sure the actual reason of the cuncurrenty.  Is it a good habit to queue all ajax requests?



              Yeah, search the forum about concurrent calls to conversation errors. I find this a serious design flaw.