3 Replies Latest reply on Jun 15, 2009 8:36 PM by Arbi Sookazian

    entityManager getting null intermittently

    Dev Kumar Newbie

      We are having a PAGE scoped action class in which entityManager is used via seam injection. There are methods in this action class which are being invoked through ajax calls from the xhtml. We have noticed that sometimes the injected value of entityManager is null for some of the requests. This is not easily reproducible but it does occur. The application code is pretty straightforward (relevant code snippets pasted below)




      UserQueries.java:
      
      @Name("userQueries")
      @Scope(ScopeType.PAGE)
      public class UserQueries
      {
        @Logger
        private Log log;
      
        @In
        private EntityManager entityManager;
      
        List<String> address;
        
        List<String> friends;
        
        public void getAddresses()
        {
          Integer customerId = 9440; //sample id
          User user = entityManager.find(User.class, customerId);
          this.address = user.getAddresses();
        }
      
        public void getFriends()
        {
          Integer customerId = 9440;// sample id
          User user = entityManager.find(User.class, customerId);
          this.friends = user.getFriendList();
        }
        
        .....
        
        .....
        
      }
      
      profile.xhtml:
      
      ........
      ........
                <a4j:form id="profileEditForm">
                     <a4j:region id="getFriendsRegion">
                          <a4j:commandButton id="refreshFriendsBtn" action="#{userQueries.getFriends}"
                               value="Refresh Friends List" reRender="friendsPanel"></a4j:commandButton>
                     </a4j:region>
      
      .........
      .........
      .........
      
                     <a4j:region id="getAddressRegion">
                          <a4j:commandButton id="refreshAddressBtn" action="#{userQueries.getAddresses}"
                               value="Refresh Addresses" reRender="addressPanel"></a4j:commandButton>
                     </a4j:region>
      
      
                     
                </a4j:form>
      
      
      ........
      ........



      Any suggestions? Has anyone faced similar issue?


      We are using seam 2.1.2.CR2 and RichFaces 3.3.1.GA. Any help is highly appreciated.


      Thanks,
      Dev