Hi all, I posted this in the acegi forum some time ago and I didnt get any answer, so I'm gonna try here.
This is my question, is there a way of applaying Acegi MethodSecurityInterceptor and hibernateTransactionManger to the same class?
In both cases the creation of a proxy is needed.
------------------------------------------------------------------------------------
This is my scenario:
I am using acegi to secure the calls to my methods, so I create I proxy for those classes with methods that I want to secure.
Now I want to apply a hibernateTransaciontionManager to those methods, so I also need another definition that creates a new proxy for those classes.Code:<bean id="autoProxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"> <property name="interceptorNames"> <list><value>methodSecurityInterceptor</value></list> </property> <property name="beanNames"> <list><value>targetObjectName</value></list> </property> <property name="proxyTargetClass" value="true"/> </bean>
Code:<tx:advice id="txAdvice" transaction-manager="txManager"> <!-- the transactional semantics... --> <tx:attributes> <!-- all methods starting with 'get' are read-only --> <tx:method name="get*" read-only="true"/> <!-- other methods use the default transaction settings (see below) --> <tx:method name="*"/> </tx:attributes> </tx:advice> <!-- ensure that the above transactional advice runs for any execution of an operation defined by the FooService interface --> <aop:config> <aop:pointcut id="fooServiceOperation" expression="execution(* x.y.service.FooService.*(..))"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="fooServiceOperation"/> </aop:config>
The problem is that the second time , Spring is trying to create a proxy of a proxy, so I get the following exception.
Does anyone know any workaround for this? Thanks.Code:org.springframework.aop.framework.AopConfigException: Couldn't generate CGLIB subclass of class [class $Proxy2]: 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 $Proxy2 Caused by: java.lang.IllegalArgumentException: Cannot subclass final class class $Proxy2 at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:446) at net.sf.cglib.transform.TransformingClassGenerator.generateClass(TransformingClassGenerator.java:33) at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25) at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:215) at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377) at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:285) at org.springframework.aop.framework.Cglib2AopProxy.getProxy(Cglib2AopProxy.java:200) at org.springframework.aop.framework.Cglib2AopProxy.getProxy(Cglib2AopProxy.java:145) at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:72)


Reply With Quote