[jboss-user] [EJB 3.0] - Problem with lazy initialization - no session or session was

korg do-not-reply at jboss.com
Thu Aug 24 09:31:07 EDT 2006


Hi, 

previously we used hibernate to manage our transactions and we were responsible of closing sessions in our session beans, so we closed it only when the thread that called the session bean was killed.  this way, it was possible for another bean (in another deployed package in jboss) to retrieve entity bean and access fields that were lazy initialized.

We changed our way of doing things to use EJB EntityManager, but since then it's impossible to access fields that have been lazy initialized.  I have entity beans and session beans deployed in a .ejb3 file and business logic beans in another .ejb3 file.  One of my BL bean calls a session bean to retrieve a list of entities and when I try to access fields that are lazy initialized, I get the folowing error:

org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.cardinal.dal.entity.infrastructure.PhysicalLocation.a
ppAccessDeviceVws, no session or session was closed


I read somewhere that this is the case when I try to access those fields outside of the classloader boundaries, so I tried to deploy my application in an ear file containing all my .ejb3 files and everything required.  When I deploy it, I still get the same exception mentionned above.

Is there a way to access lazy initialized entities outside of my session beans?  Is there a way to tell JBoss "hey, this application is in the same class loader than this one", so the session would remain open?

Thx a lot for help!

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3967226#3967226

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3967226



More information about the jboss-user mailing list