0 Replies Latest reply: Sep 2, 2013 10:36 AM by Rama.krishna RSS

    Trying to call stateless session bean from MDB

    Rama.krishna

      Folks,

       

      Am working on RAD and WAS 8.

       

      I have an MDB. And a stateless session bean (AOBean under EJB project).

      While the listener listens to the messages from queue, it also tries to persist to db. I want to achieve this via a method of AOBean (through instantiating session bean or by injection).

       

      I have been sucessful by invoking a method from AOBean class -  that method just returns a string (without any objects being passed)

       

      Problem:

      I am getting IllegalStateException when I try to invoke a method of AOBean class, that has an object as a parameter

      For eg:

      MDB

      @EJB(name="ejb/TransactionMgrAOBean", mappedName="ejb/TransactionMgrAOBean")
      ITransactionMgrAO tranAO;
          public void onMessage(Message message) {
           TextMessage textMessage = (TextMessage) message;
           boolean status = false;
        try {

         TransactionVO tranVO =  getTransactionVO();//Here building the object to be passed to session bean
         String status1  = tranAO.getVersion(tranVO);
        }catch(Exception e){
        }

      }

       

      AOBean

      @Stateless
      @Remote({ ITransactionMgrAO.class })
      @WebService
      public class TransactionMgrAOBean {

      public String getVersion(TransactionVO tranVO) throws Exception{

        try{
      //business logic 
        }
        } catch(Exception e){
        throw e;
        }
        return true;
      }
      }

       

      TransactionVO implements Serializable has also inner static classes that are not Serializable.

      EXCEPTION: At runtime we are getting exception saying that the inner classes are not serialized.

       

      REASON why we are invoking session bean from MDB? We found that if we invoke any service from AOBean the transaction management was successful. We are using sessionContext.setRollBackonly when an exception occurs. Tranasactions are not rolled back when any db exception occurs if we invoke business logic methods from Model layer of another NON-EJB package.

       

      Hope I have provided enough information!