PDA

View Full Version : Attempt to update step execution id=1 with out of date version (1)



ndefreitas
Mar 4th, 2008, 10:56 PM
Any idea why this is happening?

23:54:10,515 INFO main Environment:509 - Hibernate 3.2.3
23:54:10,515 INFO main Environment:542 - hibernate.properties not found
23:54:10,531 INFO main Environment:676 - Bytecode provider name : cglib
23:54:10,578 INFO main Environment:593 - using JDK 1.4 java.sql.Timestamp handling
23:54:10,796 INFO main HbmBinder:300 - Mapping class: org.springframework.batch.sample.domain.CustomerCr edit -> CUSTOMER
23:54:10,890 INFO main ConnectionProviderFactory:72 - Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSource ConnectionProvider
23:54:11,203 INFO main SettingsFactory:89 - RDBMS: MySQL, version: 5.0.51a-community-nt
23:54:11,218 INFO main SettingsFactory:90 - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.5 ( Revision: ${svn.Revision} )
23:54:11,234 INFO main Dialect:152 - Using dialect: org.hibernate.dialect.MySQLDialect
23:54:11,234 INFO main TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
23:54:11,234 INFO main TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
23:54:11,250 INFO main SettingsFactory:143 - Automatic flush during beforeCompletion(): disabled
23:54:11,250 INFO main SettingsFactory:147 - Automatic session close at end of transaction: disabled
23:54:11,250 INFO main SettingsFactory:154 - JDBC batch size: 15
23:54:11,250 INFO main SettingsFactory:157 - JDBC batch updates for versioned data: disabled
23:54:11,250 INFO main SettingsFactory:162 - Scrollable result sets: enabled
23:54:11,250 INFO main SettingsFactory:170 - JDBC3 getGeneratedKeys(): enabled
23:54:11,250 INFO main SettingsFactory:178 - Connection release mode: on_close
23:54:11,250 INFO main SettingsFactory:202 - Maximum outer join fetch depth: 2
23:54:11,250 INFO main SettingsFactory:205 - Default batch fetch size: 1
23:54:11,250 INFO main SettingsFactory:209 - Generate SQL with comments: disabled
23:54:11,250 INFO main SettingsFactory:213 - Order SQL updates by primary key: disabled
23:54:11,250 INFO main SettingsFactory:382 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
23:54:11,265 INFO main ASTQueryTranslatorFactory:24 - Using ASTQueryTranslatorFactory
23:54:11,265 INFO main SettingsFactory:221 - Query language substitutions: {}
23:54:11,265 INFO main SettingsFactory:226 - JPA-QL strict compliance: disabled
23:54:11,265 INFO main SettingsFactory:231 - Second-level cache: enabled
23:54:11,265 INFO main SettingsFactory:235 - Query cache: disabled
23:54:11,265 INFO main SettingsFactory:369 - Cache provider: org.hibernate.cache.NoCacheProvider
23:54:11,265 INFO main SettingsFactory:250 - Optimize cache for minimal puts: disabled
23:54:11,265 INFO main SettingsFactory:259 - Structured second-level cache entries: disabled
23:54:11,265 INFO main SettingsFactory:279 - Echoing all SQL to stdout
23:54:11,281 INFO main SettingsFactory:286 - Statistics: disabled
23:54:11,281 INFO main SettingsFactory:290 - Deleted entity synthetic identifier rollback: disabled
23:54:11,281 INFO main SettingsFactory:305 - Default entity-mode: pojo
23:54:11,281 INFO main SettingsFactory:309 - Named query checking : enabled
23:54:11,312 INFO main SessionFactoryImpl:161 - building session factory
23:54:11,593 INFO main SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
23:54:12,562 INFO main SimpleJobLauncher:130 - No TaskExecutor has been set, defaulting to synchronous executor.
23:54:12,703 INFO main SimpleJobLauncher:84 - Job: [SimpleJob: [name=locFixedWidthJob]] launched with the following parameters: [{}{}{}]
23:54:12,843 DEBUG main RepeatTemplate:429 - Starting batch step.
23:54:12,843 DEBUG main RepeatTemplate:196 - Batch operation about to start at count=0
23:54:12,859 DEBUG main RepeatTemplate:429 - Starting batch step.
23:54:12,859 DEBUG main RepeatTemplate:196 - Batch operation about to start at count=0
23:54:12,859 DEBUG main SimpleFlatFileItemReader:143 - Opening flat file for reading: class path resource [data/fixedLengthImportJob/input/LocationBatchInput.txt]
23:54:13,078 INFO main ProcessorLogAdvice:53 - Processed: com.iso.la.batch.domain.HomeAddress@16e334a
23:54:13,078 DEBUG main RepeatTemplate:400 - Batch is complete according to policy and result value.
23:54:13,312 DEBUG main JdbcStepDao:546 - Truncating long message before update of StepExecution: StepExecution: id=1, name=step1, taskCount=1, commitCount=1, rollbackCount=1
23:54:13,312 DEBUG main SimpleFlatFileItemReader:182 - Closing flat file for reading: class path resource [data/fixedLengthImportJob/input/LocationBatchInput.txt]
23:54:13,343 DEBUG main JdbcJobDao:406 - Truncating long message before update of JobExecution: JobExecution: id=1, startTime=Tue Mar 04 23:54:12 EST 2008, endTime=Tue Mar 04 23:54:13 EST 2008, job=[JobInstance: id=1, JobParameters=[{}{}{}], Job=[SimpleJob: [name=locFixedWidthJob]]]
23:54:13,359 INFO main SimpleJobLauncher:90 - Job: [SimpleJob: [name=locFixedWidthJob]] failed with the following parameters: [{}{}{}]
org.springframework.dao.OptimisticLockingFailureEx ception: Attempt to update step execution id=1 with out of date version (1)
at org.springframework.batch.execution.repository.dao .JdbcStepDao.update(JdbcStepDao.java:566)
at org.springframework.batch.execution.repository.Sim pleJobRepository.saveOrUpdate(SimpleJobRepository. java:262)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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.saveOrUpdate(Unknown Source)
at org.springframework.batch.execution.step.simple.Si mpleStepExecutor.execute(SimpleStepExecutor.java:2 84)
at org.springframework.batch.execution.step.simple.Ab stractStep.execute(AbstractStep.java:131)
at org.springframework.batch.execution.job.simple.Sim pleJob.execute(SimpleJob.java:82)
at org.springframework.batch.execution.launch.SimpleJ obLauncher$1.run(SimpleJobLauncher.java:85)
at org.springframework.core.task.SyncTaskExecutor.exe cute(SyncTaskExecutor.java:49)
at org.springframework.batch.execution.launch.SimpleJ obLauncher.run(SimpleJobLauncher.java:80)
at org.springframework.batch.execution.bootstrap.supp ort.CommandLineJobRunner.start(CommandLineJobRunne r.java:212)
at org.springframework.batch.execution.bootstrap.supp ort.CommandLineJobRunner.main(CommandLineJobRunner .java:258)
23:54:13,359 ERROR main CommandLineJobRunner:216 - Job Terminated in error:
org.springframework.dao.OptimisticLockingFailureEx ception: Attempt to update step execution id=1 with out of date version (1)
at org.springframework.batch.execution.repository.dao .JdbcStepDao.update(JdbcStepDao.java:566)
at org.springframework.batch.execution.repository.Sim pleJobRepository.saveOrUpdate(SimpleJobRepository. java:262)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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.saveOrUpdate(Unknown Source)
at org.springframework.batch.execution.step.simple.Si mpleStepExecutor.execute(SimpleStepExecutor.java:2 84)
at org.springframework.batch.execution.step.simple.Ab stractStep.execute(AbstractStep.java:131)
at org.springframework.batch.execution.job.simple.Sim pleJob.execute(SimpleJob.java:82)
at org.springframework.batch.execution.launch.SimpleJ obLauncher$1.run(SimpleJobLauncher.java:85)
at org.springframework.core.task.SyncTaskExecutor.exe cute(SyncTaskExecutor.java:49)
at org.springframework.batch.execution.launch.SimpleJ obLauncher.run(SimpleJobLauncher.java:80)
at org.springframework.batch.execution.bootstrap.supp ort.CommandLineJobRunner.start(CommandLineJobRunne r.java:212)
at org.springframework.batch.execution.bootstrap.supp ort.CommandLineJobRunner.main(CommandLineJobRunner .java:258)

Choucri FAHED
Mar 5th, 2008, 04:03 AM
Hello, I've had exactly the same problem, you can find more details here (http://forum.springframework.org/showthread.php?t=49647).
Unfortunately, I have not figured out why yet. I haven't moved to m5 either (it might be already solved), I'm waiting for the 1.0 release to come out.

Hope it helps,
Choucri

ndefreitas
Mar 5th, 2008, 10:34 AM
When I switch back to using the fixedLengthImportJob sample job it works fine. The difference is that this line returns 0 in my job, but returns 1 in the sample:

int count = jdbcTemplate.update(getUpdateStepExecutionQuery(), parameters, new int[] { Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.CHAR,Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER });

So I figured something was wrong with my usage of the FixedWidthFlatFileWriter - I thought I could just define it as an ItemWriter, and tell it where to write the output file. Can this be done? Or do I need to implement two additional classes (CustomerCreditUpdateWriter & FlatFileCustomCreditWriter) like the tradeJob sample?

p.s. Tracking down these bean defs across multiple *job.xml files is wearing me down man.

ndefreitas
Mar 5th, 2008, 10:53 AM
I implemented equivalents for CustomerCreditUpdateWriter & FlatFileCustomCreditWriter and that seems to work now.

iluvatar
Mar 5th, 2008, 12:22 PM
that error in my case appeared because spring batch was handling the autoincrementing columns and it was trying to insert an ID on the table that already existed. On the examples it works fine because all the tables are deleted on start. In my case I let ORACLE handle the incrementing column and the problem is solved.

lucasward
Mar 5th, 2008, 03:11 PM
There was definitely a little bug in M4 that was causing this error, but it should be fixed in M5.