0 Replies Latest reply on Aug 21, 2004 6:48 PM by jlukiano

    errors: Caller pointcuts on servlets

    jlukiano Newbie

      I'm trying to apply the caller pointcut below to show me the parameters sent to the servlet by the http request:

       <aspect class="br.com.ilheus.hotels.aspects.LoggingAspectPER_CLASS" scope="PER_CLASS" />
       <bind pointcut="call(java.lang.String javax.servlet.ServletRequest->getParameter(java.lang.String)) AND withincode(void br.com.ilheus.hotels.web.ReservaServlet->doPost(..))">
       <advice name="servletRequestGetParameterAdvice" aspect="br.com.ilheus.hotels.aspects.LoggingAspectPER_CLASS" />
       </bind>
      

      It seems to compile but when I execute the report mode of AopC the error "Unable to figure out calledmethod of a caller
      pointcut" appears:

      [aopc] java.lang.ExceptionInInitializerError
      [aopc] at sun.misc.Unsafe.ensureClassInitialized(Native Method)
      [aopc] at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:20)
      [aopc] at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
      [aopc] at java.lang.reflect.Field.acquireFieldAccessor(Field.java:779)
      [aopc] at java.lang.reflect.Field.getFieldAccessor(Field.java:760)
      [aopc] at java.lang.reflect.Field.get(Field.java:228)
      [aopc] at org.jboss.aop.standalone.Compiler.loadFile(Compiler.java:173)
      [aopc] at org.jboss.aop.standalone.Compiler.compile(Compiler.java:140)
      [aopc] at org.jboss.aop.standalone.Compiler.main(Compiler.java:61)
      [aopc] Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Unable to figure out calledmethod of a caller pointcut

      Also, the web container could not instantiate the servlet after the compilation:

      16:57:44,982 INFO [Engine] StandardContext[/ilheus]Marking servlet Reserva as u
      navailable
      16:57:44,982 ERROR [Engine] StandardWrapperValve[Reserva]: Allocate exception fo
      r servlet Reserva
      javax.servlet.ServletException: Error instantiating servlet class br.com.ilheus.
      hotels.web.ReservaServlet
      at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.
      java:986)


      I had applied other caller pointcut to the servlet successfully. Does anybody know why I could not intercept the
      HttpServletRequest object?

      Another abnormal end I had was that a NullPointerException occurs when my servlet processes if I configure my aspect as
      per instance:
       <aspect class="br.com.ilheus.hotels.aspects.LoggingAspect" scope="PER_INSTANCE" />
      


      The error is:

      23:21:09,233 ERROR [Engine] StandardWrapperValve[Reserva]: Servlet.service() for
      servlet Reserva threw exception
      java.lang.NullPointerException
      at org.jboss.aop.ClassInstanceAdvisor.getPerInstanceAspect(ClassInstance
      Advisor.java:98)
      at org.jboss.aop.advice.PerInstanceAdvice.invoke(PerInstanceAdvice.java:
      48)
      at org.jboss.aop.joinpoint.MethodCalledByMethodInvocation.invokeNext(Met
      hodCalledByMethodInvocation.java:60)
      at org.jboss.aop.ClassAdvisor.invokeCaller(ClassAdvisor.java:1453)
      at br.com.ilheus.hotels.web.ReservaServlet.br$com$ilheus$hotels$web$Rese
      rvaServlet$doPost$aop(ReservaServlet.java)
      at br.com.ilheus.hotels.web.ReservaServlet.doPost(ReservaServlet.java)
      at br.com.ilheus.hotels.web.ReservaServlet.br$com$ilheus$hotels$web$Rese
      rvaServlet$doGet$aop(ReservaServlet.java)
      at br.com.ilheus.hotels.web.ReservaServlet.doGet(ReservaServlet.java)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      ...

      In this case none pointcut works.