Hi,
I want to weave interceptors which loaded by a user-defined class loader (like
NetworkClassLoader), but I got a javassist.NotFoundException. My code is as follows
| ClassLoader loader = new ... // my class loader
| Thread.currentThread().setContextClassLoader(loader);
| Class clazz = Class.forName("aspect.GreetingInterceptor", false, loader);
|
| AdviceBinding binding = new AdviceBinding();
| binding.setPointcutExpression("execution(* *.Test->*(..))");
| binding.addInterceptor(clazz);
| AspectManager.instance().addBinding(binding);
|
| Test t = new Test();
| t.print();
|
My class loader reads aspect.GreetingInterceptor.class file and calls defineClass() to
load it. At the end of the code above, aspect.GreetingInterceptor is supposed to be
invoked. When aspect.GreetingInterceptor is in classpath and specified as
addInterceptor(aspect.GreetingInterceptor.class), it works fine. However, I got following
exception when aspect.GreetingInterceptor is loaded dynamically.
| Exception generating JoinPoint_print4216308509294254048_1: aspect.GreetingInterceptor
| java.lang.RuntimeException: Error generating joinpoint class for joinpoint
Method[method=public void
| Test.print()]
| at
org.jboss.aop.instrument.JoinPointGenerator.doGenerateJoinPointClass(JoinPointGenerator.java:321
| )
| ...
|
| Caused by: javassist.NotFoundException: aspect.GreetingInterceptor
| at javassist.ClassPool.get(ClassPool.java:436)
| at
org.jboss.aop.util.ReflectToJavassist.classToJavassist(ReflectToJavassist.java:49)
| at
org.jboss.aop.instrument.JoinPointGenerator$AdviceSetup.<init>(JoinPointGenerator.java:1390)
| ...
|
Does anyone know how I can use dynamically loaded class as an interceptor?
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4148725#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...