1 Reply Latest reply on Jun 14, 2012 6:49 PM by kathleenshen

    NPE occurs randomly in Production evn

    kathleenshen


      We've used seam for our project about 3 years, the version is 2.1.1.GA.

      Recently, we experienced following issue: NPE occurs randomly in Production evn.

      For our case,

      1. Two classes:  AacaDetailGetAction.java, GetAccount.java, all in CONVERSATIONAL scope;

      2. Account component is outjected from GetAccount.java and injected to AacaDetailGetAction.java

      3. Each time when load a new account or update the account in GetAccount.java,   setAccount() method will be called and trigger event  EVENT_ACCOUNT_RELOADED, that will cause Observer method init() in AacaDetailGetAction.java to be called.

      4. NPE randomly happens for the injected account component in following logger line in init() method in Prod env.

         logger.debug("Loading AACA information from customer account with account number: "
                       + account.getClearTextCustomerAccountId());

       

      Related code is as follows:

      **********************************************************************************************
      @Name("aacaDetailGetAction")
      @Conversational
      @Scope(ScopeType.CONVERSATION)
      public class AacaDetailGetAction{

      @In
           protected Account account
      ...

      @Create
          @Observer(AccountGetAction.EVENT_ACCOUNT_RELOADED)
           public void init() {
            //account becomes NULL randomly only in Prod evn.

             logger.debug("Loading  information from customer account with account number: " + account.getCustomerAccountId());
      ...}

      }
      **********************************************************************************************


      @Name("accountGetAction")
      @Scope(ScopeType.CONVERSATION)
      public class AccountGetAction {

      @Out(required = false)
           protected Account account;

      ....

         private void setAccount(Account account) {
               // need to add the below as the @In value can be null otherwise
               this.account = account;

               Contexts.getConversationContext().set("account", account);

               events.raiseEvent(EVENT_ACCOUNT_RELOADED, this.account);
           }

      ....


      }
      }


      Questions:

      1. Is there anything wrong for above code?

      2. Does this randomly occurring NPE is related to seam components injection/disinjection?  I see a bug filed for this issue, but seems not fixed yet:
      https://issues.jboss.org/browse/JBSEAM-4739


      3. Putting @Create and @Observer for the same init() method is not a good idea, but not sure that will cause some problem.

      Thanks so much!!


      Kathleen