0 Replies Latest reply on Nov 19, 2002 6:42 PM by nqin

    java.lang.IllegalStateException: A CMR problem

    nqin

      Helped needed.

      I have entity bean "class" and entity bean "section" with one-to-many relationship. Both entity beans have only local interface. And have a session bean.

      When my session bean call class.getSection(). It throws a exception- CMR can only be accessed inside the transaction which CMR is created.

      Here is some thread discussed about this issue before. The solution they suggested is about specification for container managed transaction. But that is just the case I have already did long time ago.

      I specify my session bean with "required" container-managed transaction and both entity beans with "required" container-managed transaction, which suggests that my entity bean method will be included inside the transaction of session bean method which called entity bean method.

      However this is not the case and I still got the exception.

      So I modified my session bean method to following:

      InitialContext lcontext=new InitialContext();
      UserTransaction transaction=(UserTransaction)lcontext.lookup("UserTransaction"); transaction.begin();
      try{
      col.addAll(theClass.getSection());
      } catch(Exception e)
      { }

      And this time it works.

      But it seems even I specify "required" for my session bean there is still no transaction initialied when I use my session bean.

      Wouldn't this be wrong?