How to use javax/persistence/spi/PersistenceUnitInfo.getValidationMode() with WAS 6.1

Vicky picture Vicky · Oct 17, 2011 · Viewed 7.7k times · Source

I am using JPA 2.0 with Spring and hibernate in my project.

However, the runtime is WAS 6.1.

Compilation goes fine.

However, during deployment of the application, I get the following error:

com.ibm.ws.exception.RuntimeError: java.lang.RuntimeException: java.lang.NoSuchMethodError: javax/persistence/spi/PersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode;

On searching for PersistenceUnitInfo class using ctrl + shift + T, I found it located in the following jars:

\IBM\SDP\runtimes\base_v61\lib\j2ee.jar

and

\WEB-INF\lib\hibernate-jpa-2.0-api-1.0.1.Final

I extracted above class from both the JARS and decompiled them using JAD for comparison.

I found that method getValidationMode() is not present in j2ee.jar but is present in the hibernate-jpa jar.

Is this the reason for the error I am getting ??? How to resolve it ?? How can I tell websphere to look for the class in the hibernate jar and not in server runtime lib ???

Answer

MaDa picture MaDa · Oct 17, 2011

You cannot use JPA 2.0 with Websphere 6.1, no matter what you do. As you noticed, it's wired up into the WAS internals pretty deeply. You have two options:

  1. Migrate to WAS 7.0 with appropriate feature pack (more info in my other answer).
  2. Downgrade your Hibernate to 3.3.2 GA with JPA 1.0.