[jboss-user] [JBoss AOP] - Catching LazyInitialization exception within an Interceptor

mlouna do-not-reply at jboss.com
Wed Nov 28 06:26:54 EST 2007



Catching LazyInitialization exception within an aop Interceptor

Setup

1.JBoss AS 4.2.0 GA
2.EJB 3 persistence layer of data Model.
3.UI that calls a Delegation layer that JNDI lookup and returns EJBs back to UI

The Idea

1. To write an Interceptor that intercept calls of form 
"my.persistence.*->get*()".
2. Try to invoke the Called Method
3. Catch LazyInitialization exception
4. If caught, Persist Target Object and Invoke Called Method with the new attached Target Object

Problem 

Though I can see that LazyInitialization is thrown, it is never getting caught within the Interceptor.

Help

will be greatly appreciated...
 
Code

>aop>
    >bind pointcut="call(* com.my.proj.persistence.*->get*())">
       >interceptor class="com.proj.aop.MyInterceptor"/>
   >/bind>
>/aop>

try {
    methodInvocation.getCalledMethod().invoke(methodInvocation.getTargetObject(), methodInvocation.getArguments());
} catch (LazyInitializationException ex) {
    // do things
}	

OR 

try {
  methodInvocation.invokeNext();
} catch (LazyInitializationException ex) {
    // do things
}	



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

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



More information about the jboss-user mailing list