导入aop上下文会导致Cglib错误

时间:2014-05-19 11:23:20

标签: java spring spring-aop

错误堆栈跟踪。

Caused by: org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class com.sun.proxy.$Proxy20]: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: Cannot subclass final class class com.sun.proxy.$Proxy20
    at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:218)
    at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:111)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:477)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:362)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:409)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.postProcessObjectFromFactoryBean(AbstractAutowireCapableBeanFactory.java:1655)
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:162)
    ... 23 more
Caused by: java.lang.IllegalArgumentException: Cannot subclass final class class com.sun.proxy.$Proxy20
    at org.springframework.cglib.proxy.Enhancer.generateClass(Enhancer.java:446)
    at org.springframework.cglib.transform.TransformingClassGenerator.generateClass(TransformingClassGenerator.java:33)
    at org.springframework.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
    at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
    at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
    at org.springframework.cglib.proxy.Enhancer.create(Enhancer.java:285)
    at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:206)
    ... 30 more

aop配置文件。

    

<aop:aspectj-autoproxy proxy-target-class="true" />

<bean id="methodBeforeAdviceImpl"
    class="com.x.y.common.aop.advice.MethodBeforeAdviceImpl" />
<bean id="methodBeforeAfterLogAdvice"
    class="com.x.y.common.aop.advice.MethodBeforeAfterLogAdvice" />
<bean id="exceptionLoggingAdvice"
    class="com.x.y.common.aop.advice.ExceptionLoggingAdvice" />
<!-- <aop:aspectj-autoproxy /> -->
<aop:config>
    <aop:pointcut id="methodLoggingPointcut"
        expression="execution(* com.samsung.alterego..*.*(..))" />


    <aop:advisor advice-ref="methodBeforeAfterLogAdvice"
        pointcut-ref="methodLoggingPointcut" id="methodLoggingInterceptorAdvisor" />

    <aop:advisor advice-ref="exceptionLoggingAdvice"
        pointcut-ref="methodLoggingPointcut" id="exceptionLoggingAdviceInterceptorAdvisor" />

    <!-- <aop:advisor advice-ref="methodBeforeAdviceImpl" pointcut-ref="methodLoggingPointcut" 
        id="methodBeforeAdviceImplAdvisor" /> -->
</aop:config>

这个问题只有在我与mogo db集成时才能看到。它无法为存储库[@repository]和服务[@services]

创建代理

0 个答案:

没有答案