Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Websphere 8.5 with JPA 2.1

IBM used to have a feature pack to put JPA 2.0 into WAS 7. WAS 8.5.5 evidently comes with JPA 2.0. But we have an app we just upgraded to Hibernate 4, which needs JPA 2.1. I can't find a link for a WAS 8.5 feature pack to push to JPA 2.1.

Has anyone else used Hibernate 4 in WAS 8.5? If so, how? Without a feature pack, we get NoSuchMethodError on javax.persistence classes.

like image 244
Entropy Avatar asked May 19 '14 19:05

Entropy


People also ask

What version of Java does WebSphere 8.5 use?

Java SE 8 offers support for WebSphere applications to use the latest available Java features and standards. Attention: Starting in version 8.5. 5.11, the default versions of Java are Java SE 6 or Java SE 8.

What version of Java does 8.5 5 support?

In versions 8.5. 5.11, 8.5. 5.12, and 8.5. 5.13, you can install either Java SE 6 or Java SE 8 as the version of Java SE contained in the /java and /java64 directories in WebSphere Application Server and used by default during server and node configuration.

Does WebSphere 9 support Java 11?

Java 11 is not supported on Traditional WebSphere. The page you are referencing is mentioning WebSphere in general terms as an umbrella. WebSphere (base) includes tWAS and Liberty.


1 Answers

Hibernate 4.3.7.Final can be used in Websphere Application Server 8.5.5 with following configuration:

  • Pack hibernate-jpa-2.1.jar in your application and set classloader policy to PARENT_LAST.

    Hibernate 4.3.7.Final is not compatible with the JPA 2.0 API provided by Websphere 8.5.5

  • Set JVM property com.ibm.websphere.persistence.ApplicationsExcludedFromJpaProcessing=* to disable Websphere JPA initialization.

    Without this you will get following SAXParseException during startup as Websphere attempts to parse the persistence.xml according to JPA 2.0 schema.

Caused by: org.xml.sax.SAXParseException: expected root element {http://java.sun.com/xml/ns/persistence}persistence
        at com.ibm.ws.jpa.management.JaxbUnmarshaller.startElement(JaxbUnmarshaller.java:310)
  • Apply the work around for issue JPA-4 in your application.

    The issue was reported for using Hibernate's JPA 2 API instead of Webspheres JPA 1 API, while the work around is also applicable to Hibernate's JPA 2.1 API with some minor changes:

    You need to replace HibernatePersistence with HibernatePersistenceProvider as the former has been deprecated.

    Without this you will get following ClassCastException during startup as Hibernate's JPA 2.1 API will load all PersistenceProvider classes, including the Websphere one exposed in classpath.

Caused by: java.lang.ClassCastException: com.ibm.websphere.persistence.PersistenceProviderImpl incompatible with javax.persistence.spi.PersistenceProvider
        at javax.persistence.Persistence$1.isLoaded(Persistence.java:110)
        at org.hibernate.validator.internal.engine.resolver.JPATraversableResolver.isReachable(JPATraversableResolver.java:56)
like image 65
Parker Wang Avatar answered Sep 23 '22 05:09

Parker Wang