Hi, in my spring batch program ( v1.1.3 ), i suddenly keep getting that error
This problem did not appear when i configure my log4j.logger.org.springframework to ERROR. This is the snippet of my configuration ( very straightforward, reading from file and save to db by calling a DAO )
PHP Code:
<bean id="helloStep"
class="org.springframework.batch.core.step.item.SimpleStepFactoryBean">
<property name="transactionManager" ref="transactionManager" />
<property name="jobRepository" ref="dbJobRepository" />
<property name="itemReader" ref="reader" />
<property name="itemWriter" ref="itemWriter" />
<property name="commitInterval" value="100" />
</bean>
<bean id="reader" class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="resource" ref="customerNegativeInputFile" />
<property name="firstLineIsHeader" value="true" />
<property name="lineTokenizer" ref="customerNegativeCompositeFixedLengthTokenizer" />
<property name="fieldSetMapper">
<bean class="testagain.CustomerNegativeMapper" >
<property name="dateFormat" value="yyyyMMdd hhmmssSSS" />
</bean>
</property>
</bean>
<bean id="customerNegativeCompositeFixedLengthTokenizer" class="testagain.CompositeFixedLengthTokenizer">
<property name="fixedLengthTokenizer" ref="customerNegativeFixedLengthTokenizer" />
<property name="footerRecordLength" value="19" />
</bean>
<bean id="customerNegativeFixedLengthTokenizer"
class="org.springframework.batch.item.file.transform.FixedLengthTokenizer">
<property name="names"
value="Record Indicator, Customer Name, New IC Number, Old IC Number, Card Number 1, Card Issuer 1, Card Number 2, Card Issuer 2, Reason Listed, Date Added, Add User, Last Maint Date, Last Maint User, Last Maint Time" />
<property name="columns"
value="1-1,2-31,32-43,44-55,56-71,72-91,92-107,108-127,128-287,288-295,296-307,308-315,316-327,328-335" />
</bean>
<bean id="itemWriter" class="testagain.LogWriter"> <property
name="genericDAO" ref="genericDAO"/>
</bean>
when i configure my logging to debug then i got :
PHP Code:
15:54:08 DEBUG [SessionFactoryUtils] Closing Hibernate Session
Exception in thread "main" java.lang.RuntimeException: java.lang.Error: SQLWarning chain holds value that is not a SQLWarning
at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.rethrow(SimpleJobLauncher.java:99)
at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:91)
at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:81)
at wew.StartBatch.main(StartBatch.java:29)
Caused by: java.lang.Error: SQLWarning chain holds value that is not a SQLWarning
at java.sql.SQLWarning.getNextWarning(SQLWarning.java:96)
at org.springframework.jdbc.core.JdbcTemplate.handleWarnings(JdbcTemplate.java:1222)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:592)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:619)
at org.springframework.batch.core.repository.dao.JdbcExecutionContextDao.updateExecutionAttribute(JdbcExecutionContextDao.java:193)
at org.springframework.batch.core.repository.dao.JdbcExecutionContextDao.saveOrUpdateExecutionContext(JdbcExecutionContextDao.java:130)
at org.springframework.batch.core.repository.dao.JdbcExecutionContextDao.saveOrUpdateExecutionContext(JdbcExecutionContextDao.java:109)
at org.springframework.batch.core.repository.dao.JdbcStepExecutionDao.saveOrUpdateExecutionContext(JdbcStepExecutionDao.java:142)
at org.springframework.batch.core.repository.support.SimpleJobRepository.saveOrUpdateExecutionContext(SimpleJobRepository.java:254)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy0.saveOrUpdateExecutionContext(Unknown Source)
at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:201)
at org.springframework.batch.core.job.SimpleJob.execute(SimpleJob.java:100)
at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:86)
... 3 more
I try to debug to the source code level and this problem is thrown by the method updateExecutionAttribute as well as insertExecutionAttribute in this line:
PHP Code:
Integer affectedRows = (Integer) getJdbcTemplate().execute(getQuery(UPDATE_STEP_EXECUTION_CONTEXT), callback);
From debugging, i find that this callback code is probably the culprit
PHP Code:
else if (type == AttributeType.LONG) {
ps.setString(1, AttributeType.LONG.toString());
ps.setString(2, null);
ps.setDouble(3, 0.0);
ps.setLong(4, ((Long) value).longValue());
lobCreator.setBlobAsBytes(ps, 5, null);
}
I browse to http://jira.springframework.org/browse/BATCH-820 for the Lob issue and i decided to change the code
lobCreator.setBlobAsBytes(ps, 5, null); to setBlob(lobCreator, ps, 5, value); and it wont throw that error again.
Furthermore i try to debug the root cause of exception and in this SQLWarning class
PHP Code:
public SQLWarning getNextWarning() {
try {
return ((SQLWarning)getNextException());
} catch (ClassCastException ex) {
// The chained value isn't a SQLWarning.
// This is a programming error by whoever added it to
// the SQLWarning chain. We throw a Java "Error".
throw new Error("SQLWarning chain holds value that is not a SQLWarning");
}
}
the getNextException() is actually "com.ibm.db2.jcc.c.SqlException: DB2 SQL error: SQLCODE: -301, SQLSTATE: 07006, SQLERRMC: 8"
I created the schema from the provided scripts though
can anybody pinpoint what am i doing wrong here ?
thanks
ballistic_realm