Forums Register Login
Accessing CMR collection from servlet
Hi Friends,
I have a many to many relationship which is returning a collection. When I am accessing that collection from servlet it is giving this exception.
14:45:14,176 ERROR [STDERR] java.lang.IllegalStateException: A CMR collection may only be used within the transction in which it was created When I am accessing it from my session bean it working fine. Is there anyway I can access from servlet.
Thanks in adv.
The Stack trace and the EJB spec say the same thing:

A CMR collection may only be used within the transction in which it was created.

Your entity beans have a transaction attribute of "Required"?.
Since no transaction is being started from within the servlet, the CMR gets realized in the new transaction started by the entity bean method.
U need to be starting a transaction from within your servlet before accessing the CMR. I *think* a UserTransaction started by a servlet will get propogated to the CMT of the entity bean.
If you do that you s'd not have a problem accessing the CMR within the UserTransaction started by you.
Your session bean must also be having a transaction attribute of "Required" , so you are able to access the CMR within the session bean.
Thanks your suggestion solved my problem. I have done this


This thread has been viewed 792 times.

All times above are in ranch (not your local) time.
The current ranch time is
Oct 16, 2018 08:14:07.