无法为App Engine上标有@Transactional注释的类创建代理

时间:2015-03-20 13:17:20

标签: google-app-engine spring-transactions spring-orm

我正在App Engine上尝试示例应用。我在这里尝试JPA事务管理器如下。

<context:component-scan base-package="com.pokuri.havasay"/>
    <context:annotation-config/>

    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
        <property name="persistenceUnitName" value="pokuri-havasay"/>
    </bean>

    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="entityManagerFactory" />
    </bean>

    <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>

    <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>

我已经注释了我的服务,没有与org.springframework.transaction.annotation.Transactional的接口,如下所示

@Service
@Transactional
public class UserManagementService {

}

现在我看到在App Engine上启动app时会遇到代理创建异常

[INFO] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userManagementService' defined in file [E:\workspace\pokuri-havasay\target\pokuri-havasay-1.0-SNAPSHOT\WEB-INF\classes\com\pokuri\havasay\user\services\UserManagementService.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Could
[INFO]  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)
[INFO]  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
[INFO]  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
[INFO]  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
[INFO]  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
[INFO]  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
[INFO]  at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
[INFO]  at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
[INFO]  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
[INFO]  at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
[INFO]  at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
[INFO]  at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
[INFO]  at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548)
[INFO]  at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
[INFO]  at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
[INFO]  at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
[INFO]  at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
[INFO]  at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
[INFO]  at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
[INFO]  at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
[INFO]  at com.google.appengine.tools.development.JettyContainerService.reloadWebApp(JettyContainerService.java:422)
[INFO]  at com.google.appengine.tools.development.JettyContainerService$2.filesChanged(JettyContainerService.java:380)
[INFO]  at org.mortbay.util.Scanner.reportBulkChanges(Scanner.java:486)
[INFO]  at org.mortbay.util.Scanner.reportDifferences(Scanner.java:352)
[INFO]  at org.mortbay.util.Scanner.scan(Scanner.java:280)
[INFO]  at org.mortbay.util.Scanner$1.run(Scanner.java:232)
[INFO]  at java.util.TimerThread.mainLoop(Timer.java:555)
[INFO]  at java.util.TimerThread.run(Timer.java:505)
[INFO] Caused by: org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class com.pokuri.havasay.user.services.UserManagementService]: Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
[INFO]  at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:206)
[INFO]  at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:109)
[INFO]  at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:447)
[INFO]  at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:333)
[INFO]  at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:293)
[INFO]  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:422)
[INFO]  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1571)
[INFO]  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
[INFO]  ... 27 more
[INFO] Caused by: org.springframework.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
[INFO]  at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:237)
[INFO]  at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
[INFO]  at org.springframework.cglib.proxy.Enhancer.create(Enhancer.java:285)
[INFO]  at org.springframework.aop.framework.CglibAopProxy.createProxyClassAndInstance(CglibAopProxy.java:227)
[INFO]  at org.springframework.aop.framework.ObjenesisCglibAopProxy.createProxyClassAndInstance(ObjenesisCglibAopProxy.java:66)
[INFO]  at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:202)
[INFO]  ... 34 more
[INFO] Caused by: java.lang.reflect.InvocationTargetException
[INFO]  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[INFO]  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[INFO]  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[INFO]  at java.lang.reflect.Method.invoke(Method.java:483)
[INFO]  at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:130)
[INFO]  at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:384)
[INFO]  at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:219)
[INFO]  ... 39 more
[INFO] Caused by: java.lang.LinkageError: loader (instance of  com/google/appengine/tools/development/IsolatedAppClassLoader): attempted  duplicate class definition for name: "com/pokuri/havasay/user/services/UserManagementService$$EnhancerBySpringCGLIB$$5f9cad7d"
[INFO]  at java.lang.ClassLoader.defineClass1(Native Method)
[INFO]  at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
[INFO]  ... 46 more
[INFO]

但是当我在tomcat上部署相同的战争时,我没有看到任何问题,并且能够为服务创建代理。如果我已经实现了接口,那就没问题了。当我没有接口时,我才会看到这个问题。

请指导我解决此问题

0 个答案:

没有答案