Announcement Announcement Module
Collapse
No announcement yet.
SDN use of JtaTransactionManager causes Spring Batch to not work Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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(FrameworkServlet.java:894)

    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.

    Thanks

    Mark Spritzler

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

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

    Mark

    Comment


    • #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?

      Comment

      Working...
      X