I am trying to set up Hibernate. But when i try to create my Session Factory, with this code:
Configuration configuration = new Configuration();
configuratio
NoSuchMethodError indicates that you have loaded wrong version of jar that has no method named like which you have used.
I highly recommend you to use hibernate 4.0 or little lower which turn out to be more stable to transplant.
The problem arises from having similar packaged structure jar.
In my case, I had javaee6 as provided, and javax.validation1.1.0.Final both have the package javax.validation.spi.
Since I used Maven, I placed javax.validation1.1.0 dependency on top of javaee6. So I can use 1.1.0 methods. Otherwise, if the javaee6 is on top I cannot access/ override validation1.1.0 methods.
It compiled fine, but while running in Tomee 1.7.5 WebProfile I faced NoSuchMethodError. So, added the javax.validation1.1.0 Final jar to lib folder of Tomee, but still somehow javaee6 jar's validation got triggered first.
So I renamed the file javax.validation1.1.0.Final to ijavax.validation1.1.0.Final, so that when alphabetically ordered it gets loaded before javaee6, then it worked!!
Check here for class loader ordering of jars in tomcat Order of loading jar files from lib directory