Failed to create proxy for classes marked with @Transactional annotation on App Engine

0 views
Skip to first unread message

Pokuri via StackOverflow

unread,
Mar 20, 2015, 9:22:44 AM3/20/15
to google-appengin...@googlegroups.com

I am trying sample app on App Engine. Here I am trying JPA Transaction manager as follows.

<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"/>

And I have annotated my service without interface with org.springframework.transaction.annotation.Transactional as follows

@Service
@Transactional
public class UserManagementService {

}

Now I see that on starting app on App Engine getting following proxy creation exception

[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]

But when I deploy the same war on tomcat I don't see any issue and spring able to create proxy for the services.

Please guide me in fixing this



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/29167418/failed-to-create-proxy-for-classes-marked-with-transactional-annotation-on-app

Pokuri via StackOverflow

unread,
Mar 22, 2015, 9:32:57 AM3/22/15
to google-appengin...@googlegroups.com

But when I deploy the same war on tomcat I don't see any issue and spring able to create proxy for the services. And no issue if I have implemented interfaces. When I don't have interfaces then only I see this issue.

Reply all
Reply to author
Forward
0 new messages