Announcement Announcement Module
Collapse
No announcement yet.
java.lang.IllegalArgumentException when exit code is NOOP Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • java.lang.IllegalArgumentException when exit code is NOOP

    Hi,

    I have a job restartable with a step which has property allowStartIfComplete = true.
    The first time I run my job, it ends by completed status and exit code.
    The second time, I have the following error:
    ERROR - BatchMain.start(170) | Job Terminated in error:
    java.lang.IllegalArgumentException: [Assertion failed] - this argument is required; it must not be null
    at org.springframework.util.Assert.notNull(Assert.jav a:112)
    at org.springframework.util.Assert.notNull(Assert.jav a:123)
    at org.springframework.batch.item.ExecutionContext.pu tString(ExecutionContext.java:53)
    at org.springframework.batch.execution.repository.dao .JdbcStepExecutionDao$1.processRow(JdbcStepExecuti onDao.java:101)
    at org.springframework.jdbc.core.JdbcTemplate$RowCall backHandlerResultSetExtractor.extractData(JdbcTemp late.java:1309)
    at org.springframework.jdbc.core.JdbcTemplate$1.doInP reparedStatement(JdbcTemplate.java:628)
    at org.springframework.jdbc.core.JdbcTemplate.execute (JdbcTemplate.java:566)
    at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:616)
    at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:645)
    at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:661)
    at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:669)
    at org.springframework.batch.execution.repository.dao .JdbcStepExecutionDao.findExecutionContext(JdbcSte pExecutionDao.java:119)
    at org.springframework.batch.execution.repository.dao .JdbcStepExecutionDao$StepExecutionRowMapper.mapRo w(JdbcStepExecutionDao.java:359)
    at org.springframework.jdbc.core.RowMapperResultSetEx tractor.extractData(RowMapperResultSetExtractor.ja va:92)
    at org.springframework.jdbc.core.JdbcTemplate$1.doInP reparedStatement(JdbcTemplate.java:628)
    at org.springframework.jdbc.core.JdbcTemplate.execute (JdbcTemplate.java:566)
    at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:616)
    at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:645)
    at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:653)
    at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:685)
    at org.springframework.batch.execution.repository.dao .JdbcStepExecutionDao.getStepExecution(JdbcStepExe cutionDao.java:412)
    at org.springframework.batch.execution.repository.Sim pleJobRepository.getLastStepExecution(SimpleJobRep ository.java:265)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:64)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:615)
    at org.springframework.aop.support.AopUtils.invokeJoi npointUsingReflection(AopUtils.java:301)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.invokeJoinpoint(ReflectiveMethodInvocat ion.java:182)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :149)
    at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:106)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
    at org.springframework.aop.interceptor.ExposeInvocati onInterceptor.invoke(ExposeInvocationInterceptor.j ava:89)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:204)
    at $Proxy0.getLastStepExecution(Unknown Source)
    at org.springframework.batch.execution.job.SimpleJob. shouldStart(SimpleJob.java:147)
    at org.springframework.batch.execution.job.SimpleJob. execute(SimpleJob.java:88)
    at org.springframework.batch.execution.launch.SimpleJ obLauncher$1.run(SimpleJobLauncher.java:87)
    at org.springframework.core.task.SyncTaskExecutor.exe cute(SyncTaskExecutor.java:49)
    at org.springframework.batch.execution.launch.SimpleJ obLauncher.run(SimpleJobLauncher.java:82)
    at com.natixis.sphinx.batch.BatchMain.start(BatchMain .java:166)
    at com.natixis.sphinx.batch.BatchMain.main(BatchMain. java:212)
    and then the status is FAILED while exit code is NOOP.
    I have change the ExitCodeMapper like :
    Map<String, Integer> ecmMap = new HashMap<String, Integer>();
    ecmMap.put(ExitStatus.FINISHED.getExitCode(), new Integer(0));
    ecmMap.put(ExitStatus.FAILED.getExitCode(), new Integer(8));
    ecmMap.put(ExitStatus.UNKNOWN.getExitCode(), new Integer(8));
    ecmMap.put(ExitStatus.CONTINUABLE.getExitCode(), new Integer(0));
    ecmMap.put(ExitStatus.NOOP.getExitCode(), new Integer(0));
    ecmMap.put(ExitCodeMapper.JOB_NOT_PROVIDED, new Integer(8));
    ecmMap.put(ExitCodeMapper.NO_SUCH_JOB, new Integer(8));
    ecmMap.put(ExitStatusExceptionClassifier.FATAL_EXC EPTION, new Integer(8));
    ecmMap.put(ExitStatusExceptionClassifier.JOB_INTER RUPTED, new Integer(8));

    ((SimpleJvmExitCodeMapper)exitCodeMapper).setMappi ng(ecmMap);
    The Failed status is caused by the error.
    I don't understand why there is an error. Is this normal?

    Thanks in advance.

  • #2
    if allowStartIfComplete=false, the result is the same (an error the second time I run my job).

    This problem is coming when I use JdbcCursorItemReader, here is my job.xml file:
    <import resource="classpath:simple-container-definition.xml" />

    <bean id="ExtractionClientsJob" parent="simpleJob">
    <property name="steps">
    <list>
    <bean id="Extraction" parent="simpleStep">
    <property name="streams" ref="clientFileWriter"/>
    <property name="commitInterval" value="2" />
    <property name="allowStartIfComplete" value="false" />
    <property name="itemReader" ref="DBInputTemplate" />
    <property name="itemWriter" ref="clientFileWriter"/>
    </bean>
    </list>
    </property>
    </bean>

    <!-- INFRASTRUCTURE SETUP -->
    <bean id="DBInputTemplate" class="org.springframework.batch.io.cursor.JdbcCur sorItemReader">
    <property name="dataSource" ref="dataSource" />
    <property name="saveState" value="true" />
    <property name="sql">
    <value> select p.ceseqo, p.cocivi,p.nompat,p.nommar,p.prenom,p.preno2,p.dah eme,p.cosecu,p.cositf,a.librue,a.copost,a.libvil,a .copays,a.coposn,a.copayn,a.libvin,c.cochar,c.dahe m1,c.numrib from sphmclient c, sphmadresse a, sphmpersonne p where c.cochar=7 and c.copers=p.ceseqo and p.ceseqo=a.copers order by p.ceseqo</value>
    </property>
    <property name="mapper">
    <bean class="com.natixis.sphinx.batch.modele.mapping.Cli entRowMapper" />
    </property>
    </bean>

    <bean id="clientFileWriter" class="org.springframework.batch.io.file.FlatFileI temWriter">
    <property name="resource" ref="resourceSortie1" />
    <property name="lineAggregator" >
    <bean class="org.springframework.batch.io.file.transform .DelimitedLineAggregator">
    <property name="delimiter" value=";"/>
    </bean>
    </property>
    <property name="fieldSetUnmapper" >
    <bean class="com.natixis.sphinx.batch.modele.mapping.Cli entFieldSetCreator" />
    </property>
    <property name="shouldDeleteIfExists" value="true"/>
    </bean>

    <bean id="mapContext" class="com.natixis.sphinx.batch.domain.Context">
    <property name="map">
    <map>
    <entry key="resourceSortie1" value-ref="resourceSortie1"/>
    <entry key="dataSource" value-ref="dataSource"/>
    </map>
    </property>
    </bean>

    <bean id="resourceSortie1" class="java.lang.String">
    <constructor-arg value="file:data/output/${batch.scheduleDate}.clients.txt"/>
    </bean>
    When I use my DbItemReader, there isn't any problem.
    <import resource="classpath:simple-container-definition.xml" />

    <bean id="ExtractionClientsJob" parent="simpleJob">
    <property name="steps">
    <list>
    <bean id="Extraction" parent="simpleStep">
    <property name="streams" ref="clientFileWriter"/>
    <property name="commitInterval" value="2" />
    <property name="allowStartIfComplete" value="false" />
    <property name="itemReader" ref="DbItemReader" />
    <property name="itemWriter" ref="clientFileWriter"/>
    </bean>
    </list>
    </property>
    </bean>

    <!-- INFRASTRUCTURE SETUP -->

    <bean id="DbItemReader" class="com.natixis.sphinx.batch.reader.DbItemReade r">
    <property name="dataSource" ref="dataSource" />
    <property name="sql">
    <value> select p.ceseqo, p.cocivi,p.nompat,p.nommar,p.prenom,p.preno2,p.dah eme,p.cosecu,p.cositf,a.librue,a.copost,a.libvil,a .copays,a.coposn,a.copayn,a.libvin,c.cochar,c.dahe m1,c.numrib from sphmclient c, sphmadresse a, sphmpersonne p where c.cochar=7 and c.copers=p.ceseqo and p.ceseqo=a.copers order by p.ceseqo</value>
    </property>
    <property name="mapper">
    <bean class="com.natixis.sphinx.batch.modele.mapping.Cli entRowMapper" />
    </property>
    </bean>

    Comment


    • #3
      It looks to me like the problem is in this line of code:

      [CODE]
      if (saveState) {
      Assert.notNull(executionContext, "ExecutionContext must not be null");
      String skipped = skippedRows.toString();
      executionContext.putString(getKey(SKIPPED_ROWS), skipped.substring(1, skipped.length() - 1));
      executionContext.putLong(getKey(CURRENT_PROCESSED_ ROW), currentProcessedRow);
      executionContext.putLong(getKey(SKIP_COUNT), skipCount);
      }
      [CODE]

      Specifically, the line that puts the skipped rows into the execution context. String#substring(int, int) will return an empty string if acted upon another empty string, which I'm assuming it probably was in your case. However, upon restart, the database result came back as null, and the ExecutionContext#putString method throws an error if it's null, which it honestly shouldn't, I'll create a jira issue to have that fixed.

      Comment


      • #4
        Here's the issue:

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

        Comment


        • #5
          Thanks, I'm waiting for the fix version 1.0.0-rc1.

          Comment


          • #6
            JdbcCursorItemReader with saveState=true

            I am now in rc1 version.

            When I use JdbcCursorItemReader with saveState=true, if I have an error and I restart my job, the following error happened:
            2008-03-18 16:15:11,125 ERROR - Job Terminated in error:
            java.lang.IllegalArgumentException: Value: [ nullmust be serializable.Object of class [null] must be an instance of interface java.io.Serializable
            at org.springframework.util.Assert.isInstanceOf(Asser t.java:337)
            at org.springframework.batch.item.ExecutionContext.pu t(ExecutionContext.java:67)
            at org.springframework.batch.item.ExecutionContext.pu tString(ExecutionContext.java:53)
            at org.springframework.batch.core.repository.dao.Jdbc StepExecutionDao$1.processRow(JdbcStepExecutionDao .java:101)
            at org.springframework.jdbc.core.JdbcTemplate$RowCall backHandlerResultSetExtractor.extractData(JdbcTemp late.java:1336)
            at org.springframework.jdbc.core.JdbcTemplate$1.doInP reparedStatement(JdbcTemplate.java:650)
            at org.springframework.jdbc.core.JdbcTemplate.execute (JdbcTemplate.java:588)
            at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:638)
            at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:667)
            at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:683)
            at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:691)
            at org.springframework.batch.core.repository.dao.Jdbc StepExecutionDao.findExecutionContext(JdbcStepExec utionDao.java:119)
            at org.springframework.batch.core.repository.dao.Jdbc StepExecutionDao$StepExecutionRowMapper.mapRow(Jdb cStepExecutionDao.java:359)
            at org.springframework.jdbc.core.RowMapperResultSetEx tractor.extractData(RowMapperResultSetExtractor.ja va:92)
            at org.springframework.jdbc.core.JdbcTemplate$1.doInP reparedStatement(JdbcTemplate.java:650)
            at org.springframework.jdbc.core.JdbcTemplate.execute (JdbcTemplate.java:588)
            at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:638)
            at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:667)
            at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:675)
            at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:707)
            at org.springframework.batch.core.repository.dao.Jdbc StepExecutionDao.getStepExecution(JdbcStepExecutio nDao.java:412)
            at org.springframework.batch.core.repository.support. SimpleJobRepository.getStepExecutionCount(SimpleJo bRepository.java:285)
            at com.natixis.sphinx.batch.advice.SimpleStepLogAdvic e.doRepriseLogging(SimpleStepLogAdvice.java:50)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:79)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:618)
            at org.springframework.aop.aspectj.AbstractAspectJAdv ice.invokeAdviceMethodWithGivenArgs(AbstractAspect JAdvice.java:627)
            at org.springframework.aop.aspectj.AbstractAspectJAdv ice.invokeAdviceMethod(AbstractAspectJAdvice.java: 609)
            at org.springframework.aop.aspectj.AspectJAfterAdvice .invoke(AspectJAfterAdvice.java:45)
            at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :160)
            at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:106)
            at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
            at org.springframework.aop.interceptor.ExposeInvocati onInterceptor.invoke(ExposeInvocationInterceptor.j ava:90)
            at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
            at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:204)
            at $Proxy0.getLastStepExecution(Unknown Source)
            at org.springframework.batch.core.job.SimpleJob.shoul dStart(SimpleJob.java:175)
            at org.springframework.batch.core.job.SimpleJob.execu te(SimpleJob.java:103)
            at org.springframework.batch.core.launch.support.Simp leJobLauncher$1.run(SimpleJobLauncher.java:90)
            at org.springframework.core.task.SyncTaskExecutor.exe cute(SyncTaskExecutor.java:49)
            at org.springframework.batch.core.launch.support.Simp leJobLauncher.run(SimpleJobLauncher.java:85)
            at com.natixis.sphinx.batch.BatchMain.start(BatchMain .java:156)
            at com.natixis.sphinx.batch.BatchMain.main(BatchMain. java:206)

            Comment


            • #7
              Sorry about that, i thought we had caught all of these issues:

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

              Comment

              Working...
              X