You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-user@db.apache.org by LFS <lf...@yahoo.com.br> on 2009/06/22 23:26:44 UTC

JSecurity + Transaction proxying

Hi

I'm developing a web app, and I'm facing issues with double-proxying... or so I discovered.
My app uses Datanucleus JDO for persistence, and AOP for transacion definition on business methods. When I included JSecurity code (I use version 0.9, waiting for Shiro 1.0) from the sample Spring application (my container is Spring 2.5, and JBoss AS 4.2), my DI of business beans into other beans no longer worked (trace snippet):

org.springframework.beans.TypeMismatchException:
Failed to convert property value of type [$Proxy61 implementing org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised,net.sf.cglib.proxy.Factory] to required type [MYPACKAGE.business.MyBean] for property 'myBean';

Some old post somewhere said about double-proxying, and then I figured it must be the reason, because of this JSecurity configuration I included: 

<!-- Enable JSecurity Annotations for Spring-configured beans.  Only run after
         the lifecycleBeanProcessor has run: -->
<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" depends-on="lifecycleBeanPostProcessor" />

I intend to use JSecurity annotation extensively to define security on the business and DAO layers, but also need definition of transactions for business layer, hopefully through AOP.
How can I solve this conflict?

If helpful, this is my spring metadata for transacion AOP (not quite correct, read-only does not work, still working on it):

<!-- the transactional advice (what 'happens'; see the <aop:advisor/> bean below) -->
  <tx:advice id="txAdvice" transaction-manager="txManager">
  <!-- the transactional semantics... -->
  <tx:attributes>
            <tx:method name="store*"/>
            <tx:method name="update*"/>
            <tx:method name="delete*"/>
            <tx:method name="*"  read-only="true"/>
  </tx:attributes>
  </tx:advice>
  
  <!-- ensure that the above transactional advice runs for any execution
    of an operation defined by the FooService interface -->
  <aop:config proxy-target-class="true">
  <aop:pointcut id="defaultServiceOperation" expression="execution(* MYPACKAGE.business..*Bean.*(..))"/>
  <aop:advisor advice-ref="txAdvice" pointcut-ref="defaultServiceOperation"/>
  </aop:config>

Many thanks!



      Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com

Re: JSecurity + Transaction proxying

Posted by Andy Jefferson <an...@datanucleus.org>.
> I'm developing a web app, and I'm facing issues with double-proxying... or
> so I discovered. My app uses Datanucleus JDO for persistence, and AOP for
> transacion definition on business methods. When I included JSecurity code

Hi,

You've decided to hand off transaction allocation to Spring, hence Spring will 
handle that. I would have thought that the Spring forums would be a great 
place to seek help. DataNucleus doesn't seem to be referenced at all, neither 
in configuration, nor in stack traces, hence nothing I can add.


-- 
Andy Jefferson
DataNucleus (http://www.datanucleus.org)