1

I have IBM Websphere 8.5.5.10. and hibernate-jpa-2.0-api-1.0.0.Final.jar is a default jar. However, I want to use a newer version -> hibernate-jpa-2.1-api-1.0.0.Final.jar. I set "Classes loaded with local class loader first (parent last)" and "Single class loader for application". In spite of that, I get the following error:

Caused by: java.lang.NoSuchMethodError: javax/persistence/Table.indexes()[Ljavax/persistence/Index;
...
Delegation Mode: PARENT_FIRST).
at org.hibernate.cfg.annotations.EntityBinder.processComplementaryTableDefinitions(EntityBinder.java:973) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
...

Looks like this error occurs because the old/parent's jar is loaded first. Also. please notice that Delegation Mode is PARENT_FIRST although I defined different. And I checked many times my classloader definition, restarted the application and even the server and always the same:(

Can someone help, please?

Ivan
  • 71
  • 10
  • Where is that "Delegation Mode" string coming from? That usually isn't in a stack trace like that... are you dumping out the ClassLoader.toString() for that class or something like that? – Jarid Dec 09 '16 at 14:23
  • No, I'm not dumping or anything similar. Websphere prints that – Ivan Dec 09 '16 at 14:33
  • Ah, okay... can you paste in the stuff between the exception and that point of the message? It's an odd fit for that point in an exception message, unless the JDK is formatting this a bit odd (or Hibernate is doing its own formatting). – Jarid Dec 09 '16 at 15:04
  • Caused by: java.lang.NoSuchMethodError: javax/persistence/Table.indexes()[Ljavax/persistence/Index; (loaded from file:/C:/IBM/WebSphere/AppServer/plugins/javax.j2ee.persistence.jar by org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@acd6f9c9) called from class org.hibernate.cfg.annotations.EntityBinder (loaded from ... com.ibm.ws.classloader.CompoundClassLoader@c11559f8[war:early-repayment/early-repayment.war] Local ClassPath: ... Parent: com.ibm.ws.classloader.CompoundClassLoader@7567bcff[PL][app:early-repayment] Delegation Mode: PARENT_FIRST). at org.hibernate... – Ivan Dec 09 '16 at 15:27
  • @Ivan it would be helpful if you could include the full stack trace in the question (it's hard to read a stack trace in a comment) – Andy Guibert Dec 09 '16 at 15:32
  • Okay, that's interesting. I'm wondering if the "single class loader" setting is not actually in place, because that dump of the class loader clearly indicates that it's a WAR module loader, which shouldn't exist in that configuration. My guess is that PARENT_LAST was set on the application loader, but since your JPA stuff is in the WAR, it isn't loaded with PARENT_LAST. You should be able to resolve this by either setting PARENT_LAST on the WAR module or making sure that "single class loader" is actually in place for the application. – Jarid Dec 09 '16 at 15:36
  • an alternative way to including the hibernateJPA-Jar in the war is configuring the default JPA_Provider of WAS: http://www.ibm.com/support/knowledgecenter/SSAW57_8.5.5/com.ibm.websphere.nd.doc/ae/tejb_jpadefaultpp.html – The86Freak Dec 11 '16 at 20:46

1 Answers1

2

This was already discussed in few posts , check this. You cannot use JPA 2.1 with WAS 8.5.5.x in a container managed way, as it only supports 2.0. You either have to upgrade to WAS 9.0, switch to WebSphere Liberty, or use JPA in application managed way.

Community
  • 1
  • 1
Gas
  • 17,601
  • 4
  • 46
  • 93