-
Apr 22nd, 2008, 02:17 PM
#1
declarative transaction proxy : org.springframework.aop.framework.AopConfigExcepti on
Spring : 2.5.2
JDK : 6.0_02
Hi,
I'm new to the declarative transaction management with <aop:> namespace.
I have an application that was read-only (no transaction needed until today),
every thing was working well.
My DAOs were developped using the GenericDAO pattern described in this IBM article http://www.ibm.com/developerworks/ja...enericdao.html.
I have a service layer were all services implement an Interface IService.
The application was working perfectly until I added :
<!-- the transactional advice (what 'happens'; see the <aop:advisor/> bean below) -->
<tx:advice id="transactionalAdvice" transaction-manager="transactionManager">
<!-- the transactional semantics... -->
<tx:attributes>
<!-- all methods starting with 'get' are read-only -->
<tx:method name="find*" read-only="true" />
<tx:method name="read*" read-only="true" />
<tx:method name="load*" read-only="true" />
<!-- other methods use the default transaction settings (see below) -->
<tx:method name="*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
<!-- ensure that the above transactional advice runs for any execution
of an operation defined by the GenericService subclasses -->
<aop:config>
<aop
ointcut id="serviceOperations" expression="execution(* com.company.service.api.IService+.*(..))" />
<aop:advisor advice-ref="transactionalAdvice" pointcut-ref="serviceOperations" />
</aop:config>
Now I get the following exception :
Caused by: org.springframework.aop.framework.AopConfigExcepti on: Could not generate CGLIB subclass of class [class org.joda.time.format.DateTimeFormatter]: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
at org.springframework.aop.framework.Cglib2AopProxy.g etProxy(Cglib2AopProxy.java:213)
at org.springframework.aop.framework.ProxyFactory.get Proxy(ProxyFactory.java:110)
at org.springframework.aop.framework.autoproxy.Abstra ctAutoProxyCreator.createProxy(AbstractAutoProxyCr eator.java:433)
at org.springframework.aop.framework.autoproxy.Abstra ctAutoProxyCreator.postProcessAfterInitialization( AbstractAutoProxyCreator.java:299)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyBeanPostProcessors AfterInitialization(AbstractAutowireCapableBeanFac tory.java:357)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1308)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:463)
... 72 more
Caused by: java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
at net.sf.cglib.proxy.Enhancer.emitConstructors(Enhan cer.java:718)
at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer .java:499)
at net.sf.cglib.transform.TransformingClassGenerator. generateClass(TransformingClassGenerator.java:33)
at net.sf.cglib.core.DefaultGeneratorStrategy.generat e(DefaultGeneratorStrategy.java:25)
at net.sf.cglib.core.AbstractClassGenerator.create(Ab stractClassGenerator.java:216)
at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer. java:377)
at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:2 85)
at org.springframework.aop.framework.Cglib2AopProxy.g etProxy(Cglib2AopProxy.java:201)
I don't understand AOP enough to start understanding why would transaction management manage this bean because it doesn't have any relation with my IService Interface.
Could any one help ?
I really think spring is awsome and I prefer declarativ transaction management over programmatic, any help preventing me to fall back to programmatic transaction management would be appreciated.
Last edited by paskos; Apr 22nd, 2008 at 02:23 PM.
-
Apr 24th, 2008, 08:35 AM
#2
From your exception...
"Could not generate CGLIB subclass of class [class org.joda.time.format.DateTimeFormatter]: Superclass has no null constructors but no arguments were given"
Why are you proxying DateTimeFormatter?
-
Apr 24th, 2008, 06:50 PM
#3
I don't think he is proxying DataFormatter (i mean i don't think he is doing it intentionally, but it is being proxied). I bet there is some wild pointcut hidden inside of configuration which covers DataFormater. Can you post you entire configuration?
Your DataFormatter is being proxied using CGLIB becouse it does not implement an interface (that is not your problem since it is not your class). As the error message says:" Superclass has no null constructors but no arguments were given" - which means that the DataFormatter can not be instantiated by CGLIB with default constructor and CGLIB can not use any other (known limitation).
But the real problem is as bdangubic suggested: why are you proxing it in the first place. You might not do it intentionally, but you have something that directs Spring AOP to wrap your Data Formatter into proxy.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules