Hi

I am i am trying to use Jboss AOP with simple method-pointcut 
i have written two Interceptor`s namely Logging and Tracing ..

Please find my Intreceptors here 


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{
                 return invocation.invokeNext();
      }

      System.out.println("Entering  :"+ message);

      // Continue on.  Invoke the real method or constructor.
      InvocationResponse rsp = invocation.invokeNext();
     // System.out.println("Leaving  :"+ message);
      return rsp;
   }
}


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


public class  Logging implements Interceptor {

        public String getName(){
                return "Logging";
        }

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

                        if(invocation.getType() == InvocationType.METHOD) {
                                MethodInvocation method = (MethodInvocation) 
invocation;                                
                                System.out.println("Method Logging");

                        }else if(invocation.getType() == InvocationType.CONSTRUCTOR){
                                ConstructorInvocation con  = (ConstructorInvocation) 
invocation;
                                System.out.println("Constructor Logging");
                        }else {
                                //return invocation.invokeNext();
                        }

                        return invocation.invokeNext();
        }
}

Jboss-AOP.xml

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


        

 <method-pointcut class="POJO" methodName="hello.*">
       
              
          <interceptor-ref name="Log"/>
       
 </method-pointcut> 





public class  POJO {
        
                private int counter = 0;

                public POJO(){ }

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

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

        }
}



I am using JDK-1.4.1
and jboss-aop-DR2



When i run My POJO class i am getting the following exception

ava.lang.reflect.InvocationTargetException
       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.standalone.SystemClassLoader.initialize(SystemClassLoader.java:453)
       at 
org.jboss.aop.standalone.SystemClassLoader.loadClass(SystemClassLoader.java:156)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
       at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
aused by: java.lang.NullPointerException
       at org.jboss.aop.AspectXmlLoader.deployMethodPointcut(AspectXmlLoader.java:262)
       at org.jboss.aop.AspectXmlLoader.deployXML(AspectXmlLoader.java:683)
       at org.jboss.aop.AspectXmlLoader.deployXML(AspectXmlLoader.java:818)
       ... 8 more
xception in thread "main" java.lang.Error: Error deploying aop configrations
       at 
org.jboss.aop.standalone.SystemClassLoader.initialize(SystemClassLoader.java:459)
       at 
org.jboss.aop.standalone.SystemClassLoader.loadClass(SystemClassLoader.java:156)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
       at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
aused by: java.lang.reflect.InvocationTargetException
       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.standalone.SystemClassLoader.initialize(SystemClassLoader.java:453)
       ... 3 more
aused by: java.lang.NullPointerException
       at org.jboss.aop.AspectXmlLoader.deployMethodPointcut(AspectXmlLoader.java:262)
       at org.jboss.aop.AspectXmlLoader.deployXML(AspectXmlLoader.java:683)
       at org.jboss.aop.AspectXmlLoader.deployXML(AspectXmlLoader.java:818)


       can some body help to come out of this

       Thanks and Regards
       Muneendra

<a 
href="http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3823959#3823959";>View 
the original post</a>

<a 
href="http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3823959>Reply 
to the post</a>


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
JBoss-Development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to