csvItemWriter issue
kk31 Oct 3, 2016 2:55 PMHi,
I am trying to develop standalone java batch application which reads data from DB2(v9.7) tables and writes it to csv file with out header with JDK 1.8.
here is my job.xml
<chunk item-count="10000" >
<reader ref="jdbcItemReader">
<properties>
<property name="sql" value="xxx />
<property name="driver-name" value="com.ibm.db2.jcc.DB2Driver" />
<property name="url" value="jdbc:db2://xxx:123/schemaName" />
<property name="user" value="xxxx" />
<property name="password" value="xxxx" />
<property name="beanType" value="java.util.List" />
</properties>
</reader>
<processor ref="xxxxItemProcessor"></processor>
<writer ref="csvItemWriter">
<properties>
<property name="resource" value="test.out" />
<property name="writeMode" value="overwrite" />
<property name="preference" value="STANDARD_PREFERENCE" />
<property name="beanType" value="java.util.List" />
<property name="header" value="' '" />
</properties>
</writer>
</chunk>
It throws the following error message while writing it into csv by using csvItemWriter.
Oct 03, 2016 1:25:29 PM org.jberet.runtime.runner.ChunkRunner readProcessWriteItems
ERROR: ProcessingInfo{count=1197, timerExpired=false, itemState=RUNNING, chunkState=DEPLETED, checkpointPosition=-1, readPosition=1197, failurePoint=null}
Oct 03, 2016 1:25:29 PM org.jberet.runtime.runner.ChunkRunner run
ERROR: item-count=10000, time-limit=0, skip-limit=-1, skipCount=0, retry-limit=-1, retryCount=0
Oct 03, 2016 1:25:29 PM org.jberet.runtime.runner.ChunkRunner run
ERROR: JBERET000007: Failed to run job job, xxxxxx, org.jberet.job.model.Chunk@e4fe4dd
java.lang.IllegalArgumentException: columns to write should not be empty on line 4
at org.supercsv.io.AbstractCsvWriter.writeRow(AbstractCsvWriter.java:162)
at org.supercsv.io.AbstractCsvWriter.writeRow(AbstractCsvWriter.java:126)
at org.supercsv.io.CsvListWriter.write(CsvListWriter.java:71)
at org.jberet.support.io.CsvItemWriter.writeItems(CsvItemWriter.java:152)
at org.jberet.runtime.runner.ChunkRunner.doCheckpoint(ChunkRunner.java:522)
at org.jberet.runtime.runner.ChunkRunner.readProcessWriteItems(ChunkRunner.java:317)
at org.jberet.runtime.runner.ChunkRunner.run(ChunkRunner.java:201)
at org.jberet.runtime.runner.StepExecutionRunner.runBatchletOrChunk(StepExecutionRunner.java:219)
at org.jberet.runtime.runner.StepExecutionRunner.run(StepExecutionRunner.java:140)
at org.jberet.runtime.runner.CompositeExecutionRunner.runStep(CompositeExecutionRunner.java:164)
at org.jberet.runtime.runner.CompositeExecutionRunner.runFromHeadOrRestartPoint(CompositeExecutionRunner.java:88)
at org.jberet.runtime.runner.JobExecutionRunner.run(JobExecutionRunner.java:59)
at org.jberet.spi.JobExecutor$1.run(JobExecutor.java:99)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Oct 03, 2016 1:25:29 PM org.jberet.support.io.CsvItemWriter close
INFO: JBERET060502: Closing resource MyBatchletTest_test.out in class org.jberet.support.io.CsvItemWriter
Exception in thread "main" javax.batch.operations.BatchRuntimeException: The job did not complete: job.xml
at org.jberet.se.Main.main(Main.java:56)
After reading thru other threads Result set is closed
I updated my classpath jberet-support-1.3.0.Beta3.jar file and still having same issue.
If we use jacksonCSVItemWriter, it is happy and writes it into file and job is successful . So is it csvItemWriter issue or jdbcItemReader issue?
Thanks