Announcement Announcement Module
Collapse
No announcement yet.
UnexpectedRollbackException instead of MyException is thrown when using AOP Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • UnexpectedRollbackException instead of MyException is thrown when using AOP

    Hi,

    I've tried 2 differents configs for managing tx in my app

    The first one is fully parametered with annotations, i.e on each method
    i've got :
    Code:
    @Transactional(readOnly = false,propagation= Propagation.REQUIRED)//, rollbackForClassName={"Throwable"})
    Each time an exception is thrown (Throwable), the first exception thrown
    is type with the exception that occured in the code. The problem with this issue is that i'm obliged to repeat thoses props on each method ( long ...)

    The second way is using the AOP config (more centralized), il looks like this :
    Code:
    <tx:annotation-driven transaction-manager="txManager"  />
    
    	<tx:advice id="txAdvice" transaction-manager="txManager">
    		<tx:attributes>
    			<tx:method name="*" rollback-for="Throwable" />
    			<tx:method name="get*" read-only="true"/>
    		</tx:attributes>
    	</tx:advice>
    
    	<aop:config>
        	<aop:pointcut id="serviceOperation" expression="execution(* com.company.service..*Service.*(..))"/>
        	<aop:advisor pointcut-ref="serviceOperation" advice-ref="txAdvice" />
      	</aop:config>
    And there no annotation on the class.
    In this 2nd way, the Exception thrown during a rollback case will be an UnexpectedRollbackException at first and MyException nested.

    How to change the conf in order to have the real exception on top level ?
    Thanks in advance


    gz
Working...
X