Hi everyone,
I have an application using spring and aop and here's the problem I'm facing :
I'm using a custom classloader to load my classes and xml context file. I'm using the setClassLoader method on my applicationContext class to use said custom classloader.
At first everything appears to work fine: I'm getting my beans. But in fact, I'm just getting 'simple' instances of my classes instead of proxies and therefore, the aop functionnalities don't work.
After debugging for a while, I've found out that the problem lies in the AbstractAutoProxyCreator class in the wrapIfNecessary method : the list of specificInterceptors is empty. Debugging a little deeper, it appears that the problem is in AspectJExpressionPointcut class in getShadowMatch :
The comment in the catch clause seems to clearly indicate that my custom classloader is the reason why it fails.Code:private ShadowMatch getShadowMatch(Method targetMethod, Method originalMethod) { synchronized (this.shadowMapCache) { ShadowMatch shadowMatch = (ShadowMatch) this.shadowMapCache.get(targetMethod); if (shadowMatch == null) { try { shadowMatch = this.pointcutExpression.matchesMethodExecution(targetMethod); } catch (ReflectionWorld.ReflectionWorldException ex) { // Failed to introspect target method, probably because it has been loaded // in a special ClassLoader. Let's try the original method instead... if (targetMethod == originalMethod) { throw ex; } shadowMatch = this.pointcutExpression.matchesMethodExecution(originalMethod); } this.shadowMapCache.put(targetMethod, shadowMatch); } return shadowMatch; } }
Anyone having an idea about how to get this to work ?
Thanks for your help


Reply With Quote