[ACCEPTED]-Websphere 8.5 with JPA 2.1-websphere

Accepted answer
Score: 12

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

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

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

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

    Without this 12 you will get following SAXParseException during startup as 11 Websphere attempts to parse the persistence.xml 10 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 9 your application.

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

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

    Without 4 this you will get following ClassCastException during startup 3 as Hibernate's JPA 2.1 API will load all 2 PersistenceProvider classes, including the Websphere one exposed 1 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)
Score: 5

Hibernate 4.2.x implements the JPA 2.0 specification, we 6 use that without any problems in WebSphere 5 8.5.5. We package the Hibernate JARs in 4 our WARs and set the provider attribute 3 in the persistence.xml to org.hibernate.ejb.HibernatePersistence.

Only 2 Hibernate 4.3.x requires JPA 2.1 and won't 1 work with WebSphere 8.5.5.

Score: 0

I was able to do that using websphere running on 2 Java 8 by making a shared library that contains

  • hibernate-jpa-2.1-api-1.0.2.Final.jar

  • hibernate-core-4.3.11.Final.jar

and 1 everything worked fine with me.

More Related questions