Error creating bean with name 'sessionFactory' defined— java.lang.NoSuchMethodError: javax/persistence/OneToMany.orphanRemoval()Z


(nagarajur) #1

Hi Guys, I am getting below exception when I am trying to publish the Spring and hibernate application :

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sessionFactory’ defined in ServletContext resource [/WEB-INF/hibernate.cfg.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax/persistence/OneToMany.orphanRemoval()Z

When I looked at dependencies tree I have only one ‘hibernate-jpa-2.0-api-1.0.1.Final’ jar file.I don’t have any other version of(hibernate-jpa-2.1-api-1.0.1.Final), so that the version conflict is not the cause for this error. I have this class (javax.persistence.OneToMany) in hibernate-jpa-2.0-api-1.0.1.Final.jar and javaee-api-7.0.jar under Project and External dependencies’ section and also in j2ee.jar under ‘websphere application server’ runtime libraries.Both hibernate-jpa-2.0-api-1.0.1.Final.jar and javaee-api-7.0.jar files have this method orphanRemoval().And j2ee.jar does not have the method in the class.

It seems(I am guessing) conflict between either (hibernate-jpa-2.0-api-1.0.1.Final.jar and javaee-api-7.0.jar files) or the application is pointing to j2ee.jar at runtime that has javax.persistence.OneToMany class that does not have the method.I am not able to confirm the problem.Please suggest me what to do in this case.

Sombody told to put hibernate-jpa-2.0-api-1.0.1.Final.jar in the websphereHomeDir/lib/ext folder manually,But that is manual step I can’t do it in production

I am not able to go further.Please help me in this case