method-pointcut Problem
muneendra78 Mar 3, 2004 3:08 AMHi
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
 
    