Discussions

EJB programming & troubleshooting: NotReentrantException in calling one bean's method from another.

  1. Dear All,
    I have the following two session beans -
    1. CountBean(Session Bean), CountObject(EJB Object) and CountHome(EJB Home)
    2. LocalBean(Session Bean), LocalObject(EJB Local Object) and LocalHome(EJB Local Home)
    In one of the CountBean's business method, I got the local object(LocalObject) as -
    InitialContext ctx = new InitialContext();
    LocalHome localHome = (LocalHome)ctx.lookup("java:comp/env/ejb/Local");
    LocalObject localObject = localHome.create();
    And, then got a reference of the remote object(of CountObject) as -
    EJBObject eO = mySessionCtx.getEJBObject();
    Finally, I called the business method(passing the above mentioned remote object "eO") of LocalBean as follows -
    localObject.passCountObject(eO);

    In the LocalBean, I have the following code snippet -
    public void passCountObject(EJBObject eO) {
    ((CountObject)eO).toTest();
    }
    I get an exception at ((CountObject)eO).toTest(); as -
    SystemErr R java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
    com.ibm.ejs.container.BeanNotReentrantException: TX_IN_METHOD

    What can be the reason for the same?
    Thanks in advance.
    Regards,
    Ashish A.
  2. You cannot recurse in EJB's..
  3. What are transaction attributes of LocalBean#passCountObject() and CountBean#toTest()??
    Your CountBean EJB is in transaction (the business method), therefore it can not participate in another one. That's normally a reason for BeanNotReentrantException
  4. The second thought: I'm not sure that result of mySessionCtx.getEJBObject()is meant to be passed over the bean's "borders". You can freely use it the POJO's calls