[Logo]
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.
Sonu
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

Sonu
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards



All times above are in ranch (not your local) time.
The current ranch time is
Nov 17, 2017 16:20:30.