Deploying application using Hibernate JPA 2.1 to IBM WebSphere gives NullPointerException

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:

  1. Create a folder in your server and put in it all the hibernate libraries

    enter image description here

  2. Create the shared library in Websphere (Environment / Shared libraries) and set it to the path of the folder you just created on the server

  3. 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

    enter image description here

  4. 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

  5. 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.

    enter image description here

  6. 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

Leave a Comment