-
1. Re: java.lang.IllegalStateException: A CMR collection may on
nqin Nov 19, 2002 6:32 PM (in response to zarni)I have a similar problem. 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 something thread discussed about this issue before. But I still think solution is not reasonable. 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. So it seems even I specify "required" for my session bean. But there is no transaction initialied when I use my session bean.
Wouldn't this be wrong? -
2. Re: java.lang.IllegalStateException: A CMR collection may on
zarni Nov 25, 2002 6:57 AM (in response to zarni)This transactions are all kind of weird!
I used UserTransaction in my jsp page and it worked fine!
But when I tried to wrap the logic in a tag like:
<init:transaction>
code...
</init:transaction>
It just won't go...