private void decorateProxyCandidate(ApplicationContext ctx) { ClassLoader cl = Thread.currentThread().getContextClassLoader(); // we need to use the child context classLoader Thread.currentThread().setContextClassLoader(ctx.getClassLoader()); try { AnnotationAwareAspectJAutoProxyCreator annotationAwareAspectJAutoProxyCreator = new AnnotationAwareAspectJAutoProxyCreator(); DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(ctx); annotationAwareAspectJAutoProxyCreator.setBeanFactory(lbf); for (ProxyRegistry candidateProxyRegistry : overridableCandidates.values()) { Object bean = candidateProxyRegistry.target; Object advicedBean = annotationAwareAspectJAutoProxyCreator.postProcessAfterInitialization(bean, candidateProxyRegistry.beanName); if (bean != advicedBean) { log.info("The bean with name {} is now proxied by {}", candidateProxyRegistry.beanName, advicedBean); candidateProxyRegistry.target = advicedBean; } } } finally { Thread.currentThread().setContextClassLoader(cl); } }