Announcement Announcement Module
No announcement yet.
SDN use of JtaTransactionManager causes Spring Batch to not work Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • SDN use of JtaTransactionManager causes Spring Batch to not work

    Basically, because of the neo4jTransactionManager is declared, setting up Spring Batch in its own DataSourceTransactionManager and separate SQL Database won't work. Spring Batch has a JobRepository that reads and writes to SQL database tables, so if you add Spring Batch to your project you need to have a datasource pointing to an SQL database. In my case I am just using the EmbeddedDatabaseFactoryBean to create an in memory sql database with hsql and runs Spring Batches table create scripts. I also created a bean for a DataSourceTransactionManager id="transactionManager" and assigned the JobRepository to it. So not to use the neo4jTransactionManager. But when the Spring Batch JobRepository goes to get the data about a job it throws an exception from the JtaTransactionManager, which in my app would be the one that SDN created.

    org.springframework.web.util.NestedServletExceptio n: Request processing failed; nested exception is org.springframework.transaction.InvalidIsolationLe velException: JtaTransactionManager does not support custom isolation levels by default - switch 'allowCustomIsolationLevels' to 'true'
    org.springframework.web.servlet.FrameworkServlet.p rocessRequest(

    So that neo4jTransactionManager seems to overtake the entire application, even if you configure other stuff to use a different transactionManager.

    Is there a fix? Is this something that needs to be corrected in SDN to allow a separate TransactionManager to be created and run on data that is stored in an SQL database, And this isn't partial where I have a domain object that stores some state in a SQL db and some in Neo4J.

    The data for Spring Batch is completely separate from any of my Neo4J backed domain objects.


    Mark Spritzler

  • #2
    I had to fully redeclare the neo4jTransactionManager bean to get it to work. with

    <bean id="neo4jTransactionManager"
            <property name="transactionManager">
                <bean class="org.neo4j.kernel.impl.transaction.SpringTransactionManager">
                    <constructor-arg ref="graphDatabaseService"/>
            <property name="userTransaction">
                <bean class="org.neo4j.kernel.impl.transaction.UserTransactionImpl">
                    <constructor-arg ref="graphDatabaseService"/>
            <property name="allowCustomIsolationLevels" value="true"/>
    And now it all works together. I guess the JobRepository in Spring Batch sets an isolation level.



    • #3
      would it be also possible from the outside to set the transactionManager.allowCustomIsolationLevels property on tx-manager?

      Would it be sensible to enable this by default?