We are trying to deploy a Java 7 Spring MVC application using Hibernate into an IBM WebSphere 8.5.5.2 server. The application runs fine on a Tomcat server, but we cannot get
Thought I would share what worked for me. I was able to use JPA 2.1 and Hibernate 4.3.11 on Websphere 8.5.5.5 by using a custom PersistenceProviderResolver so that the Websphere classes do not interfere with Hibernate https://gist.github.com/jeffsheets/aec3e94870ef903ce7efe33e00563d3c
I based it off of a post found here https://hibernate.atlassian.net/browse/JPA-4
I share what worked for me. Me and my team were able to deploy our application with Spring 4.2.4, Hibernate 5.1 and Hibernate JPA 2.1 in Websphere 8.5.5 and Websphere 7.
The key to do this is to extract all the hibernate libraries and put them in a shared library folder in your server, create in your server configuration a new class loader with parent last order and assign to this class loader the shared library containing the hibernate libraries. Then you must change the Default Java Persistence API settings to use the hibernate persistence provider and not the default WebSphere persistence provider. So the steps are the followings:
Create a folder in your server and put in it all the hibernate libraries
Create the shared library in Websphere (Environment / Shared libraries) and set it to the path of the folder you just created on the server
On WebSphere click on your server and under Server Infrastructure click on Java and Process Management / Class Loader. Click on New and select the Parent Last option. Save
Click on the new class loader you just created and click on Shared library references on the right. Here add the shared library containing the Hibernate Libraries
Now under the section Container Settings of your server click on Container Services / Default Java Persistence API settings. Here you have to specify an alternate default persistence provider. See the image below.
Now compile your application and remove from the generated war the Hibernate libraries (see image 1). Then install it in the server.
In my case the application works like a charm also in WebSphere 7.
This procedure solves javax/persistence/Table.indexes()
error and all the other compilation error caused by libraries conflict between WebSphere and Hibernate.
Reference:
https://www.ibm.com/developerworks/community/wikis/form/anonymous/api/wiki/53181ccd-bcd4-431f-b968-0b5f6d46d652/page/192a432b-28bb-4080-b037-345e5d83da76/attachment/61e74f67-1d60-4120-ba25-ad7264c9f4f6/media/AlternateJPAProviders_TestReport.pdf
The javax/persistence/Table.indexes()
is from JPA 2.1, WebSphere Application Server traditional 8.5.5.2 is using by default JPA 2.0 (OpenJPA). If you want to use Hibernate you have to override the default provider - check this post for more details.
UPDATE
Yes, you are correct. You cannot override default provider in WebSphere traditional 8.5.5.x with JPA 2.1 as container relies on 2.0 api for initialization.
If you have to use 2.1 you may use it as application managed provider not container managed. So you would need to disable JPA for your application, check this and instead of rely on container on injecting EntityManager, initialize it by your self using API.
The other option would be to consider WebSphere Liberty which supports JPA 2.1 (using EclipseLink) starting from version 8.5.5.6. It should be possible to change provider there since container supports 2.1, however I didn't have time to test it.
You can also upgrade to WebSphere Application Server v9, recently released, which supports JPA 2.1.
What worked for me is:
In the logs(copied from the OP's log), there is this:
[3/26/15 13:49:54:339 MDT] 00000066 LogHelper Z org.hibernate.jpa.internal.util.LogHelper logPersistenceUnitInformation HHH000204: Processing PersistenceUnitInfo [
name: default
...]
If you notice, it's trying to use the default persistence provider.
As such, if we do not specify explicitly the persistence provider to use, Hibernate is going to use the WAS Persistence Provider(i.e OpenJPA in this case) - and in the case of WebLogic, EclipseLink.
As WAS 8.5.5.x support only JPA 2.0(and JPA 1.0), this will not work and a bunch of errors will appear in the logs(...), such as those posted by the OP.
In order to solve it, i explicitly specified the third party persistence to Hibernate as per this post
I hope this will help someone.
I made it work with Spring Boot 2.1.4, Hibernate 5.3.9.Final and WAS 8.5.5 without any server-level changes :). The steps are outlined in my article below. Still using JPA 2.1, didn't have to downgrade to JPA 2.0 at all.
[How-to] Deploy Spring Boot 2.x apps on WebSphere 8.5.5