[jboss-user] [EJB 3.0] - remote interface and lazy init exception

mazz@jboss.com do-not-reply at jboss.com
Mon Mar 17 11:20:59 EDT 2008


I haven't found any topic on this EJB3 forum, which seems like its more appropriate here.

See this thread, "Catching LazyInitialization exception within an Interceptor":

http://www.jboss.com/index.html?module=bb&op=viewtopic&t=124693

The issue here is that my EJB3 SLSB has methods that return JPA entity objects.  Some do not have some/all of their relationships loaded (because they don't need to be due to the semantics of the SLSB method call).  Rather than force my app to load these unused relationships, we just return entities as-is.  We also don't want to have to write and maintain additional DTOs or composite objects just to support the SLSB calls.

But, if these calls are made via a @Remote method, this forces the objects to be serialized and if a relationship isn't loaded, the call will throw a LazyInitializationException even though the caller never plans on looking at the relationship data.

This is, in effect, the same thing we ran across when using WebServices (in which case we had to implement our own safe invoker code injected in the web services stuff so we avoid these exceptions - there's a thread in the JBossWS forum regarding this).

How are people getting around this?  I am assuming this will involve introducing a new AOP interceptor - has anyone done that with success?


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

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



More information about the jboss-user mailing list