Announcement Announcement Module
No announcement yet.
@Transactional + AspectJ -> Problem Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • @Transactional + AspectJ -> Problem


    Thanks for the replies and have managed to get a lot of things done but some more issues....pls do let me know what I am doing wrong

    The scenario as I explained before, is I need a new TRANSACTION for every method call that I make...but the scenario is slightly modified..

    This is my service class method:

    //No Transactional annotation

    //Method 1
    otherService.callXXX(); @Transactional(propagation=Propagation.REQUIRES_NE W)

    //Method 2
    otherService.callYYY();@Transactional(propagation= Propagation.REQUIRES_NEW)

    Now, before I call the two service methods, I have an @Around AspectJ advice which basically checks to see if this method has been run already for the day (its kind of a scheduler application)...If the method has been run, I return to the original calling method, if it has not been run, the method is executed and if thros back an error I need to store it in a database. Heres a snippet of the source code in the aspect,

    public Object doBasicProfiling(ProceedingJoinPoint pjp) throws Throwable {

    //Check if callXXX() has been run

    status = otherService1.getStatus(); @Transactional(readOnly=true)

    }catch(Exception e){
    otherService1.saveStatus(NOT_RUN) @Transactional(propagation=Propagation.REQUIRES_NE W) [PROBLEM AREA]

    Now, as you can see, I want the call to otherService1.saveStatus() to be run in a new transaction and not within the current transaction as the current transaction has already been marked for rollback due to an exception thrown in the calling method. I get the following set of errors :

    03:08:2007 12:27:42 DEBUG AnnotationTransactionAttributeSource.getTransactio nAttribute(110) | Adding transactional method [saveStatus] with attribute [PROPAGATION_REQUIRES_NEW,ISOLATION_DEFAULT]

    03:08:2007 12:27:42 DEBUG [DefaultQuartzScheduler_Worker-1] TransactionSynchronizationManager.getResource(140) | Retrieved value [[email protected] 0200c] for key [org.springframework.orm.jpa.LocalContainerEntityMa [email protected]] bound to thread [DefaultQuartzScheduler_Worker-1]

    03:08:2007 12:27:42 DEBUG [DefaultQuartzScheduler_Worker-1] JpaTransactionManager.doGetTransaction(280) | Found thread-bound EntityManager [[email protected]] for JPA transaction

    03:08:2007 12:27:42 DEBUG [DefaultQuartzScheduler_Worker-1] JpaTransactionManager.getTransaction(319) | Using transaction object [org.springframework.orm.jpa.JpaTransactionManager$ [email protected]]

    03:08:2007 12:27:42 DEBUG [DefaultQuartzScheduler_Worker-1] JpaTransactionManager.handleExistingTransaction(39 1) | Suspending current transaction, creating new transaction with name [com.iflexsolutions.wm.scheduling.service.JobSchedu lerManager.saveEODTransaction]

    03:08:2007 12:27:42 DEBUG [DefaultQuartzScheduler_Worker-1] TransactionSynchronizationManager.clearSynchroniza tion(276) | Clearing transaction synchronization

    03:08:2007 12:27:42 DEBUG [DefaultQuartzScheduler_Worker-1] TransactionSynchronizationManager.unbindResource(1 93) | Removed value [[email protected] 0200c] for key [org.springframework.orm.jpa.LocalContainerEntityMa [email protected]] from thread [DefaultQuartzScheduler_Worker-1]

    03:08:2007 12:27:42 DEBUG [DefaultQuartzScheduler_Worker-1] TransactionInterceptor.completeTransactionAfterThr owing(327) | Completing transaction for [com.iflexsolutions.wm.eod.service.EODManager.jobCa llProcEOD] after exception: java.lang.IllegalStateException: No value for key [org.springframework.jdbc.datasource.DriverManagerD [email protected]] bound to thread [DefaultQuartzScheduler_Worker-1]

    03:08:2007 12:27:42 DEBUG [DefaultQuartzScheduler_Worker-1] RuleBasedTransactionAttribute.rollbackOn(130) | Applying rules to determine whether transaction should rollback on java.lang.IllegalStateException: No value for key [org.springframework.jdbc.datasource.DriverManagerD [email protected]] bound to thread [DefaultQuartzScheduler_Worker-1]

    03:08:2007 12:27:42 DEBUG [DefaultQuartzScheduler_Worker-1] RuleBasedTransactionAttribute.rollbackOn(148) | Winning rollback rule is: null

    03:08:2007 12:27:42 DEBUG [DefaultQuartzScheduler_Worker-1] RuleBasedTransactionAttribute.rollbackOn(153) | No relevant rollback rule found: applying superclass default

    03:08:2007 12:27:42 DEBUG [DefaultQuartzScheduler_Worker-1] JpaTransactionManager.triggerBeforeCompletion(846) | Triggering beforeCompletion synchronization

    03:08:2007 12:27:57 ERROR [DefaultQuartzScheduler_Worker-1] TransactionInterceptor.completeTransactionAfterThr owing(335) | Application exception overridden by rollback exception

    java.lang.IllegalStateException: No value for key [org.springframework.jdbc.datasource.DriverManagerD [email protected]] bound to thread [DefaultQuartzScheduler_Worker-1]


    03:08:2007 12:28:07 WARN [DefaultQuartzScheduler_Worker-1] MethodInvokingJobDetailFactoryBean$MethodInvokingJ ob.executeInternal(276) | Invocation of method 'execute' on target class [class com.iflexsolutions.wm.eod.service.impl.EODExecuteM anagerImpl] failed

    java.lang.IllegalStateException: Cannot deactivate transaction synchronization - not active