1 Reply Latest reply on May 18, 2009 6:51 AM by alen_ribic

    Interceptor invoked in context of Servlet but not JSP

    alen_ribic

      I have an Interceptor that intercepts the Hibernate's LazyInitializationException. I also have Load Time Weaving turned on. This interceptor works well when called from within the context of the Web Application Servlet. (By well I mean the LazyInitializationException does get thrown and my Interceptor handles it.)

      However, from Servlet to JSP context, my interceptor does not get invoked.

      My JSP file has a simple call like this to an detached entity:

      <td>${actionBean.user.department.users}</td>


      The .users part throws the LazyInitializationException and should have been cough by my interceptor. The interceptor debug log doesn't run at all so I know the interceptor is not being called.

      Same example with detached entity but in my Servlet that actually works:

      User user = getUserServiceRemote().getUser(getUserId());
      log.debug("Users: " + user.getDepartment().getUsers());
      


      In the above, the .getUsers() part throws the LazyInitializationException and does get cough and handled by my interceptor.

      Why does the JSP version not get intercepted?
      Only thing I can think of is that the JSP version actually calls the Department.users attribute directly and not the getter. My pointcut is set on the getters only and not fields(attributes).

      Thanks in advance.
      -Al

        • 1. Re: Interceptor invoked in context of Servlet but not JSP
          alen_ribic

          Ok the Entity class relationship defined on the Department.getUsers is @javax.persistence.OneToMany and thats on the getter and not the attribute.
          So, JSP could not be calling the attribute directly as the LazyInitializationException is thrown and @OneToMany that would cause it is defined on the getter.

          My jboss-aop.xml if defined in a separate jar file in the root of the .ear.


          MyEAR.ear/
           |
           |-----MyEJBClient.jar/
           | |
           | |----- META-INF/jboss-aop.xml
           | |
           | |----- com.mycomp.aop.myinterceptors.*
           | |----- com.mycomp.entity.*
           |
           |-----MyWebApp.war/
           |
           |---- the Servlets + JSP