1 Reply Latest reply on Mar 4, 2004 2:49 AM by Muneendra

    caller-pointcut Error

    Muneendra Newbie


      I have a problem with Caller Point Cut..

      I have one Interceptor Tracing and one POJO class with two methods namely helloWorld and main methof.

      I confifured my Caller point cut like

      <method-pointcut class="POJO" methodName="hello.*">


      <caller-pointcut class="POJO" withinMethodName="main" calledClass="POJO" calledMethod="helloWorld">


      my Caller point cut says (Correct me if i am wrong) all the call from main method to helloWorld should be intercepted or adviced

      when i run POJO class i am getting the following exception

      Exception in thread "main" java.lang.ClassCastException
      at Tracing.invoke(Tracing.java:21)
      at org.jboss.aop.Invocation.invokeNext(Invocation.java:61)
      at org.jboss.aop.ClassAdvisor.invokeCaller(ClassAdvisor.java:745)
      at POJO.POJO$main$WithoutAdvisement(POJO.java:28)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.aop.ClassAdvisor$MethodTailInterceptor.invoke(ClassAdvisor.java:865)
      at org.jboss.aop.Invocation.invokeNext(Invocation.java:61)
      at org.jboss.aop.ClassAdvisor.invokeMethod(ClassAdvisor.java:729)
      at org.jboss.aop.ClassAdvisor.invokeMethod(ClassAdvisor.java:705)
      at POJO._added_m$1(POJO.java)
      at POJO.main(POJO.java)

      My Interceptor looks like this

      import org.jboss.aop.*;
      import java.lang.reflect.*;

      public class Tracing implements Interceptor {

      public String getName() {
      return "TracingInterceptor";

      public InvocationResponse invoke(Invocation invocation) throws Throwable{
      String message = null;

      if(invocation.getType() == InvocationType.METHOD) {

      MethodInvocation method = (MethodInvocation)invocation;
      message = "method: " + method.method;

      }else if (invocation.getType() == InvocationType.CONSTRUCTOR){

      ConstructorInvocation c = (ConstructorInvocation)invocation;
      message = "constructor: " + c.constructor;

      }else if (invocation.getType() == InvocationType.FIELD_READ){

      FieldInvocation field = (FieldInvocation)invocation;
      message = "Field : " + field.field;

      return invocation.invokeNext();

      System.out.println("Entering :"+ message);
      InvocationResponse rsp = invocation.invokeNext();
      return rsp;

      MY POJO.java looks like this

      public class POJO {

      public int counter = 0;

      public POJO(){

      public void helloWorld() {
      System.out.println("Testing JBoss-AOP"); // call setCounter

      public void setCounter(int counter){

      public int getCounter(){
      return counter;

      public static void main(String[] args){
      POJO c = new POJO();

      my hellowWorld Method calls setCounter method

      Please Correct me if i am missing something

      Thanks and Regards

        • 1. Re: caller-pointcut Error
          Muneendra Newbie

          Sorry for not pasting jboss-aop message properly.. it looks like this

          <?xml version="1.0" encoding="UTF-8"?>

          <method-pointcut class="POJO" methodName="hello.*">


          <caller-pointcut class="POJO" withinMethodName="main" calledClass="POJO" calledMethod="helloWorld">