Announcement Announcement Module
Collapse
No announcement yet.
java.lang.IllegalStateException: Stream is already initialized.Close before re-opene Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • java.lang.IllegalStateException: Stream is already initialized.Close before re-opene

    I am getting the below exception while using SPring batch. Trying to read the sequentiona flat file and update the database.

    Please help on this below.

    ------------------------------------------------------------------
    15-Mar-2010 14:28:25.909: ERROR AbstractStep:215 - Encountered an error executing the step
    org.springframework.batch.item.ItemStreamException : Failed to initialize the reader
    at org.springframework.batch.item.support.AbstractIte mCountingItemStreamItemReader.open(AbstractItemCou ntingItemStreamItemReader.java:139)
    at org.springframework.batch.item.support.CompositeIt emStream.open(CompositeItemStream.java:98)
    at org.springframework.batch.core.step.tasklet.Taskle tStep.open(TaskletStep.java:379)
    at org.springframework.batch.core.step.AbstractStep.e xecute(AbstractStep.java:195)
    at org.springframework.batch.core.job.AbstractJob.han dleStep(AbstractJob.java:348)
    at org.springframework.batch.core.job.flow.FlowJob.ac cess$0(FlowJob.java:1)
    at org.springframework.batch.core.job.flow.FlowJob$Jo bFlowExecutor.executeStep(FlowJob.java:135)
    at org.springframework.batch.core.job.flow.support.st ate.StepState.handle(StepState.java:60)
    at org.springframework.batch.core.job.flow.support.Si mpleFlow.resume(SimpleFlow.java:144)
    at org.springframework.batch.core.job.flow.support.Si mpleFlow.start(SimpleFlow.java:124)
    at org.springframework.batch.core.job.flow.FlowJob.do Execute(FlowJob.java:103)
    at org.springframework.batch.core.job.AbstractJob.exe cute(AbstractJob.java:250)
    at org.springframework.batch.core.launch.support.Simp leJobLauncher$1.run(SimpleJobLauncher.java:110)
    at java.lang.Thread.run(Thread.java:619)
    Caused by: java.lang.IllegalStateException: Stream is already initialized. Close before re-opening.
    at org.springframework.util.Assert.state(Assert.java: 384)
    at org.springframework.batch.item.database.JdbcCursor ItemReader.doOpen(JdbcCursorItemReader.java:460)
    at org.springframework.batch.item.support.AbstractIte mCountingItemStreamItemReader.open(AbstractItemCou ntingItemStreamItemReader.java:137)
    ... 13 more

  • #2
    Make sure your reader has the "step" scope in the bean definition. If that does not help, please show your code.

    Comment


    • #3
      Step scope not working..

      Comment


      • #4
        Originally posted by sachin.tyagi View Post
        Step scope not working..
        If that does not help, please show your code.

        Comment


        • #5
          It does't work if you use java annotation.

          @StepScope
          public JdbcCursorItemReader<String> reader() {
          JdbcCursorItemReader<String> itemReader = new JdbcCursorItemReader<String>() {

          @BeforeStep
          public void beforeStep(StepExecution stepExecution ) {
          long callCenterId = stepExecution.getJobParameters().getLong("callCent erId");
          this.setDataSource(ds);
          this.setRowMapper(new StringRowMapper<String>());
          this.setSql("SELECT guid from tbl where copied = false ");
          }
          };
          return itemReader;
          }

          Comment


          • #6
            @StepScop is not working in multithreaded environment. Let me know if I need to configure something else?

            Comment

            Working...
            X