Results 1 to 3 of 3

Thread: null pointer on INSERT into NSERT into table BATCH_JOB_EXECUTION_CONTEXT

  1. #1
    Join Date
    Sep 2006
    Location
    Work in New York City
    Posts
    127

    Default null pointer on INSERT into NSERT into table BATCH_JOB_EXECUTION_CONTEXT

    I am getting a null pointer exception when Spring Batch tries to do an INSERT into table BATCH_JOB_EXECUTION_CONTEXT. All the prior INSERT's that spring batch does into the other spring batch tables work okay. Am using MS SqlServer 2005, using 2.0.4.RELEASE of spring-batch-core with Spring Framework 2.5.6.
    The batch job was working fine with MapJobRepositoryFactoryBean. This only started today when I changed to the following.
    Are there any known bugs that could cause this, or workarounds that could circumvent this?

    Code:
    <batch:job-repository id="jobRepository"
    	 data-source="dataSource"
    	transaction-manager="txManager" 
    	isolation-level-for-create="REPEATABLE_READ"
    	table-prefix="BATCH_" />
    Code:
    snc: 97427 DEBUG springframework.jdbc.core.JdbcTemplate - Executing prepared SQL statement [INSERT INTO BATCH_JOB_EXECUTION_CONTEXT (SHORT_CONTEXT, SERIALIZED_CONTEXT, JOB_EXECUTION_ID) VALUES(?, ?, ?)]
    snc: 97427 DEBUG springframework.transaction.support.TransactionSynchronizationManager - Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@17f9a29] for key [org.apache.commons.dbcp.PoolingDataSource@162a121] bound to thread [http-8080-2]
    snc: 97427 DEBUG springframework.transaction.support.TransactionSynchronizationManager - Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@17f9a29] for key [org.apache.commons.dbcp.PoolingDataSource@162a121] bound to thread [http-8080-2]
    snc: 312461 DEBUG springframework.transaction.support.TransactionSynchronizationManager - Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@17f9a29] for key [org.apache.commons.dbcp.PoolingDataSource@162a121] bound to thread [http-8080-2]
    snc: 312461 DEBUG springframework.transaction.interceptor.TransactionInterceptor - Completing transaction for [org.springframework.batch.core.repository.JobRepository.createJobExecution] after exception: java.lang.NullPointerException
    snc: 312461 DEBUG springframework.transaction.interceptor.RuleBasedTransactionAttribute - Applying rules to determine whether transaction should rollback on java.lang.NullPointerException
    snc: 312461 DEBUG springframework.transaction.interceptor.RuleBasedTransactionAttribute - Winning rollback rule is: null
    snc: 312461 DEBUG springframework.transaction.interceptor.RuleBasedTransactionAttribute - No relevant rollback rule found: applying default rules
    ...snip...
    snc: 312649 DEBUG springframework.transaction.support.TransactionSynchronizationManager - Clearing transaction synchronization
    snc: 312649 DEBUG springframework.transaction.support.TransactionSynchronizationManager - Removed value [org.springframework.jdbc.datasource.ConnectionHolder@75479a] for key [org.apache.commons.dbcp.PoolingDataSource@162a121] from thread [http-8080-2]
    snc: 312680 DEBUG springframework.jdbc.datasource.DataSourceTransactionManager - Releasing JDBC Connection [jdbc:microsoft:sqlserver://m-sncdbd01.frb.gov:1433;NETADDRESS=000000000000;HOSTPROCESS=0;SENDSTRINGPARAMETERSASUNICODE=true;LOGINTIMEOUT=0;DATABASENAME=SNC_III;PROGRAMNAME=;SELECTMETHOD=direct;WSID=, UserName=sncInternal, SQLServer] after transaction
    snc: 312680 DEBUG springframework.jdbc.datasource.DataSourceUtils - Returning JDBC Connection to DataSource
    snc: 312680 DEBUG snc.spring.exception.CreditsExceptionResolver - doResolveException ex.class: java.lang.NullPointerException
    java.lang.NullPointerException
    	at com.microsoft.jdbc.sqlserver.tds.TDSRPCParameter.initializeUserParam(Unknown Source)
    	at com.microsoft.jdbc.sqlserver.SQLServerImplStatement.addUserParametersToRPC(Unknown Source)
    	at com.microsoft.jdbc.sqlserver.SQLServerImplStatement.execute(Unknown Source)
    	at com.microsoft.jdbc.base.BaseStatement.commonExecute(Unknown Source)
    	at com.microsoft.jdbc.base.BaseStatement.executeUpdateInternal(Unknown Source)
    	at com.microsoft.jdbc.base.BasePreparedStatement.executeUpdate(Unknown Source)
    	at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:102)
    	at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:798)
    	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:591)
    	at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:792)
    	at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:850)
    	at org.springframework.batch.core.repository.dao.JdbcExecutionContextDao.persistSerializedContext(JdbcExecutionContextDao.java:175)
    	at org.springframework.batch.core.repository.dao.JdbcExecutionContextDao.saveExecutionContext(JdbcExecutionContextDao.java:132)
    	at org.springframework.batch.core.repository.support.SimpleJobRepository.createJobExecution(SimpleJobRepository.java:138)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    Java Developer with all the usual Sun Java certifications.

  2. #2
    Join Date
    Jun 2005
    Posts
    4,232

    Default

    The error is pretty deep in com.microsoft code. Have you tried the jtds drivers? We don't test SQL Server very thoroughly, but when we do we use those drivers not the Microsoft ones.

  3. #3
    Join Date
    Jul 2011
    Posts
    15

    Default update the driver

    You are using the driver for Sqlserver 2000, which uses a preparestatement that doesn't handle null values.
    Try to use the 2005 driver instead, sqljdbc.jar

    Since both the 2000, and 2005 driver can handle urls starting with "jdbc:sqlserver" you have to be careful if you have both drivers in your classpath, as the DriverManager will pick the driver that registered itself first.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •