简体   繁体   中英

NoSuchMethodError: org.hibernate.SessionFactory.openSession()

I'm having hibernate3.jar and hibernate-core-4.2.0.CR1.jar in my classpath and I'm using Spring 3.1.3 version. Code got compiles sucessfully but while runtime I'm getting following error

2014-10-28 10:51:25,174 DEBUG [RMI TCP Connection(2)-10.126.30.203] - Target method failed for RemoteInvocation: method name 'getPriceByKeys'; parameter types [java.util.List, java.util.Date] java.lang.NoSuchMethodError: org.hibernate.SessionFactory.openSession()Lorg/hibernate/Session;

I google it but not find any solution. Please note : My project needs hibernate3.jar but at the same time my project dependent on some other 3rd party jar which inturn using hibernet4.2.0 jar.

Any help Pls ??

You need to remove multiple hibernate JAR files from your classpath . Without doing this, your application may not work as you expect; which means you need to migrate the hibernate version of your application from 3 to 4.1.

Although Spring 3.1 uses Hibernate 3 JAR files, you can still migrate to Hibernate 4. Check out Spring blog gives a small tutorial to do so.

Migrating to Spring 3.1 and Hibernate 4.1

As part of the Core-Spring course, we have a lab application that we use to show how to integrate Spring and JPA/Hibernate together. We have just upgraded it to Spring 3.1 / Hibernate 4.1, and thought we should share a few tips.

Just an update. The cause of problem is , I'm having two spring-context xml files in project (one of my project and one related to another module that I'm integrating). I'm loading context xmls from two different classes. So one of the DAO class loaded by one of spring-context xml not getting the hibernate Session .

Later on using import tag, I included 2nd spring application context file in 1st application context file and then loaded a Single application context file from the class. It solved the error.

Thanks,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM