1

I've been upgrading my frameworks (spring-ws, spring, spring-batch, hibernate) to the latest versions.

 compile group: 'org.springframework.ws', name: 'spring-ws-core', version: '3.0.4.RELEASE'
compile group: 'org.springframework', name: 'spring-context', version: '5.1.1.RELEASE'
compile group: 'org.springframework', name: 'spring-context-support', version: '5.1.1.RELEASE'
compile group: 'org.springframework', name: 'spring-tx', version: '5.1.1.RELEASE'
compile group: 'org.springframework', name: 'spring-orm', version: '5.1.1.RELEASE'
compile group: 'org.springframework', name: 'spring-web', version: '5.1.1.RELEASE'
compile group: 'org.springframework.batch', name: 'spring-batch-core', version: '4.0.1.RELEASE'
compile group: 'org.springframework.batch', name: 'spring-batch-infrastructure', version: '4.0.1.RELEASE'
compile group: 'org.hibernate', name: 'hibernate-core', version: '5.3.6.Final'

Everything seem to work fine except when i execute spring batch job, i get the following error

java.lang.NoSuchMethodError: org.hibernate.StatelessSession.createQuery(Ljava/lang/String;)Lorg/hibernate/query/Query;
at org.springframework.batch.item.database.HibernateItemReaderHelper.createQuery(HibernateItemReaderHelper.java:148)
at org.springframework.batch.item.database.HibernateItemReaderHelper.getForwardOnlyCursor(HibernateItemReaderHelper.java:122)
at org.springframework.batch.item.database.HibernateCursorItemReader.doOpen(HibernateCursorItemReader.java:185)
at org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.open(AbstractItemCountingItemStreamItemReader.java:146)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:136)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:124)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
at com.sun.proxy.$Proxy50.open(Unknown Source)
at org.springframework.batch.item.support.CompositeItemStream.open(CompositeItemStream.java:103)
at org.springframework.batch.core.step.tasklet.TaskletStep.open(TaskletStep.java:310)
at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:197)
at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:148)
at org.springframework.batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:66)
at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:67)
at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:169)
at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:144)
at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:136)
at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:308)
at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:141)
at java.lang.Thread.run(Thread.java:748)

I see that HibernateItemReaderHelper calls the createQuery method, inside this method the createQuery method of StatelessSession is called.

HibernateItemReaderHelper.creatQuery returns an object of org.hibernate.query.Query; StatelessSession.createQuery returns an object of org.hibernate.Query

I' think that is the problem, but how can i fix this? Please help

1
  • 1
    I second the answer by @dimitrisli . See my comment there. Commented Oct 24, 2018 at 7:43

1 Answer 1

1

Spring Batch Core 4.0.1.RELEASE seems to be compatible with Hibernate 5.2.12.Final as can be seen in its tag build.gradle dependency file so give that a try instead of your explicit version 5.3.6.Final.

Sign up to request clarification or add additional context in comments.

1 Comment

I second this answer. Either downgrade your hibernate version to 5.2.12.Final (or the latest 5.2.x which is 5.2.17.Final as of writing this) or upgrade Spring Batch to 4.1.0.RC1 where hibernate version has been upgraded to 5.3.6.Final.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.