Announcement Announcement Module
Collapse
No announcement yet.
Spring batch 1.0.0 FINAL : JdbcCursorItemReader not releasing Connection, ResultSet Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring batch 1.0.0 FINAL : JdbcCursorItemReader not releasing Connection, ResultSet

    Hi,

    i have a job configured with a step to read from the DB using JdbcCursorItemReader. The first time the job is run on application startup, it runs fine. However on second execution and furthur executions it fails with the error

    Code:
       
    java.lang.IllegalArgumentException: [Assertion failed] - the object argument must be null
    at org.springframework.util.Assert.isNull(Assert.java:89)
    at org.springframework.util.Assert.isNull(Assert.java:100)
    at org.springframework.batch.item.database.JdbcCursorItemReader.open(JdbcCursorItemReader.java:324)
    at org.springframework.batch.item.support.CompositeItemStream.open(CompositeItemStream.java:105)
    at org.springframework.batch.core.step.item.ItemOrientedStep.execute(ItemOrientedStep.java:264)

    Job configuration is as shown:

    Code:
       
    <bean id="simpleJob" 
              class="org.springframework.batch.core.job.SimpleJob" abstract="true" scope="prototype">
            <property name="jobRepository" ref="jobRepository"/>
            <property name="restartable" value="true"/>
        </bean>
        
       
        <bean id="simpleStep" 
              class="org.springframework.batch.core.step.item.SimpleStepFactoryBean" abstract="true" scope="prototype">
            <property name="transactionManager" ref="transactionManager"/>
            <property name="jobRepository" ref="jobRepository"/>
        </bean>
        
        <bean id="jdbcCursorItemReader" class="org.springframework.batch.item.database.JdbcCursorItemReader" abstract="true" scope="prototype">
            <property name="dataSource" ref="dataSource"/>
        </bean>
    
        <bean id="eodJob" parent="simpleJob">
            <property name="name" value="EOD_Job"/>
            <property name="steps">
                <list>
                    <bean id="EODTransactionProcessing" parent="simpleStep">
                        <property name="itemReader">
                            <bean parent="jdbcCursorItemReader">
                                <property name="sql" 
                                          value="SELECT * FROM TEMP_TX"/>
                                <property name="mapper" ref="transactionMapper"/>
                            </bean>
                        </property>
                        <property name="itemWriter" ref="transactionWriter"/>
                    </bean>
                </list>
            </property>
        </bean>
    I read about the JdbcCursorItemReader.close() method, but how or when should the same be invoked? Please guide me on the same

  • #2
    The reader should get a callback to its close() method at the end of the step. How are you starting and stopping the job?

    Comment


    • #3
      Hi Dave,

      Thanks for the reply !

      Putting a prototype scope to the bean identifier does not solve the issue.. We start the job using the run method available in SimpleJoblauncher which takes the job name and the parameters...the application context is loaded only once as part of a web app

      Thanks..Vijay

      Comment


      • #4
        I did some investigation, and it's definitely a bug. I think it hadn't been caught yet because we generally recommend that each job be run in a new ApplicationContext. (for unrelated reasons)

        Regardless, I created a Jira issue to track it:

        http://jira.springframework.org/browse/BATCH-610

        It's marked resolved, since I already fixed the issue in both 1.0.1 and 1.1. As a sidenote, 1.0.1 should be coming out on Monday.

        Comment

        Working...
        X