Announcement Announcement Module
Collapse
No announcement yet.
StoredProcedureItemReader fails due to invalid cursor position. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • StoredProcedureItemReader fails due to invalid cursor position.

    Hi,
    I have a SPitemreader reading from a database and a writer making Webservice calls with the returned information. When i run it in single threaded mode it works fine. In multi-threaded mode it fails with invalid cursor position exception. How do I make this work in multi-thread?

    org.springframework.dao.InvalidDataAccessResourceU sageException: Unexpected cursor position change.
    at org.springframework.batch.item.database.AbstractCu rsorItemReader.verifyCursorPosition(AbstractCursor ItemReader.java:364)
    at org.springframework.batch.item.database.AbstractCu rsorItemReader.doRead(AbstractCursorItemReader.jav a:446)
    at org.springframework.batch.item.support.AbstractIte mCountingItemStreamItemReader.read(AbstractItemCou ntingItemStreamItemReader.java:85)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:599)
    at org.springframework.aop.support.AopUtils.invokeJoi npointUsingReflection(AopUtils.java:307)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.invokeJoinpoint(ReflectiveMethodInvocat ion.java:183)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :150)
    at org.springframework.aop.support.DelegatingIntroduc tionInterceptor.doProceed(DelegatingIntroductionIn terceptor.java:131)
    at org.springframework.aop.support.DelegatingIntroduc tionInterceptor.invoke(DelegatingIntroductionInter ceptor.java:119)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :172)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:202)
    at $Proxy1.read(Unknown Source)
    at org.springframework.batch.core.step.item.SimpleChu nkProvider.doRead(SimpleChunkProvider.java:90)
    at org.springframework.batch.core.step.item.SimpleChu nkProvider.read(SimpleChunkProvider.java:127)
    at org.springframework.batch.core.step.item.SimpleChu nkProvider$1.doInIteration(SimpleChunkProvider.jav a:106)
    at org.springframework.batch.repeat.support.RepeatTem plate.getNextResult(RepeatTemplate.java:367)
    at org.springframework.batch.repeat.support.RepeatTem plate.executeInternal(RepeatTemplate.java:214)
    at org.springframework.batch.repeat.support.RepeatTem plate.iterate(RepeatTemplate.java:143)
    at org.springframework.batch.core.step.item.SimpleChu nkProvider.provide(SimpleChunkProvider.java:103)
    at org.springframework.batch.core.step.item.ChunkOrie ntedTasklet.execute(ChunkOrientedTasklet.java:68)
    at org.springframework.batch.core.step.tasklet.Taskle tStep$ChunkTransactionCallback.doInTransaction(Tas kletStep.java:353)
    at org.springframework.transaction.support.Transactio nTemplate.execute(TransactionTemplate.java:128)
    at org.springframework.batch.core.step.tasklet.Taskle tStep$2.doInChunkContext(TaskletStep.java:261)
    at org.springframework.batch.core.scope.context.StepC ontextRepeatCallback.doInIteration(StepContextRepe atCallback.java:76)
    at org.springframework.batch.repeat.support.TaskExecu torRepeatTemplate$ExecutingRunnable.run(TaskExecut orRepeatTemplate.java:257)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run Task(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:735)




    Here is my configuration:

    <batch:step id="abc" next="ds-call">
    <batch:tasklet task-executor="taskExecutor" throttle-limit="5">
    <batch:chunk reader="Reader" writer="Writer" commit-interval="1"/>
    </batch:tasklet>
    </batch:step>

    <bean id="Reader" class="org.springframework.batch.item.database.Sto redProcedureItemReader" scope="step">
    <property name="dataSource" ref="refDS"/>
    <property name="procedureName" value="AABC123"/>
    <property name="rowMapper">
    <bean class="mydataMapper"/>
    </property>
    <property name="saveState" value="false"></property>
    </bean>

  • #2
    If you are using ORACLE or POSTGRE Database, please set the property "refCursorPosition" inside your StoredProcedureItemReader. For example,

    Code:
    <beans:property name="refCursorPosition" value="5"/>

    Comment


    • #3
      No i am using DB2....

      Comment

      Working...
      X