Results 1 to 5 of 5

Thread: Declarative Transaction Issues With Proxies?

  1. #1
    Join Date
    Nov 2007
    Posts
    420

    Default Declarative Transaction Issues With Proxies?

    Simple declarative transaction setup

    Code:
    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        	p:dataSource-ref="dataSource"/>
    </bean>
      	
    <tx:advice id="txAdvice" transaction-manager="txManager">
        	<tx:attributes>
    	      	<tx:method name="*" propagation="REQUIRED"/>
        	</tx:attributes>
      </tx:advice>
      	
    <aop:config>
        	<aop:pointcut id="serviceOperation" expression="execution(* com.x.*.service..*Service.*(..))"/>
        	<aop:advisor advice-ref="txAdvice" pointcut-ref="serviceOperation"/>
      	</aop:config>
    This setup is not working, i.e. the services are not transaction.

    All service classes are created with BeanNameAutoProxyCreator with several advisors so I am guessing that perhaps the pointcut execution(public * com.x.*.service..*Service.*(..)) is the problem here. Any insight would be appreciated...

  2. #2

    Default

    Maybe someone can help you if you say in words what are you trying to execute with:
    execution(* com.x.*.service..*Service.*(..))
    maybe try this,
    execution(* com.x.*.service..Service*(..))

  3. #3
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    I would rather suggest
    execution(* com.x..service..*Service.*(..))

    But some examples for what should be matched might indeed be helpful.

    Regards,
    Andreas

  4. #4
    Join Date
    Nov 2007
    Posts
    420

    Default

    Thanks guys. The problem is not in the matching, I guess I wasn't clear. I am using AJDT plugin so I have 905 matches for the pointcut, no issues there. The issue is that the services that should be matched by the pointcut are created with org.springframework.aop.framework.autoproxy.BeanNa meAutoProxyCreator (several other advisors) so I just wondering if that may be the issue as to why at runtime my services are not transactional? At runtime then the service become Proxy$1.... so I am just wondering if that is a problem?

  5. #5
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,632

    Default

    I would remove the BeanNameAutoProxyCreator and do everything with the aop:config block. That way you only have 1 BeanPostProcessor creating proxies, that can prevent a lot of issues, especially when mixin class/interface proxies or only class proxing (cglib marks classes final so proxy 1 is created whereas the second is not for instance).

    However your pointcuts shouldn't be a problem if you program to interfaces you might need to add the subclass identifier which is a + so instead of

    Code:
    execution(* com.x..service..*Service.*(..))
    use

    Code:
    execution(* com.x..service..*Service+.*(..))
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •