Announcement Announcement Module
No announcement yet.
java.lang.IllegalStateException: Cannot deactivate transaction synchronization - not Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

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

    Dear All,

    [LEFT]I am facing an issue with spring transaction manager.The issue goes like this

    I have an application from where I launch a spring job(everything juns in the same jvm).My application has its own database tables to be populated.
    My application is using its own org.springframework.jdbc.datasource.DataSourceTran sactionManager .Spring batch uses its own org.springframework.jdbc.datasource.DataSourceTran sactionManager. The commit issued from my application gives the following error..

    java.lang.IllegalStateException: Cannot deactivate transaction synchronization - not active
    at nSynchronizationManager.clearSynchronization(Trans
    at nSynchronizationManager.clear(TransactionSynchroni
    at atformTransactionManager.cleanupAfterCompletion(Ab

    So ideally in this scenario where I have 2 similar transaction managers what should I do inorder to avoid the above error. I tried setting the TransactionDefinition to PROPAGATION_NESTED and TransactionSynchronization to SYNCHRONIZATION_NEVER in my application. After this the application started committing the appln specific tables but the spring batch specific tables entries where not getting committed properly..I tried setting the same transaction attributes in the sping batch job xml also..but then there was commit problem with my application code.

    Could any one please help on this issue.
    What should be the right way to execute these kind of applications where I have multiple/identical datasource transaction managers.

  • #2
    You are probably going to have a lot of headaches if you have 2 transactions managers and need to use them both at the same time. The particular problem you have encountered is that only one of them is allowed to register synchronizations for a given transaction (there is a flag I think that you can set to disable one of them, but that might not be what you want). I'm not sure why you should be seeing that, but it is only the start of what you could get into. I would recommend using a single DataSource anyway, or at least a single TransactionManager if that isn't possible.


    • #3
      Hi Dave,

      Thanks for the reply.........

      We created a single ApplicationContext to load the dataSource and transactionManager and passed the same into the 'public ClassPathXmlApplicationContext(String[] configLocations, ApplicationContext parent) throws BeansException' during job launching so that the same dataSource and transactionManager is getting used for spring batches also.

      So the issue is resolved by using a common ds and tx mgr...