Search code examples
jpaweblogic

Spring 4 + hibernate & jpa 2.1 on weblogic 10.3.5


Will I be able to run Hibernate with JPA 2.1 on weblogic 10.3.5.

I have specified the below lines in weblogic-application.xml and packaged the jpa 2.1 API jar in the EAR along with other jars.

<wls:prefer-application-packages> <wls:package-name>javax.persistence</wls:package-name> </wls:prefer-application-packages>

Some how weblogic recognizes META-INF/persistence.xml and tries to automatically create persistence unit using Eclipse Link during application deployment/startup. This is where the weblogic classloader (parent of application class loader) is trying to load the persistence unit but failing with below exception.

java.lang.IllegalArgumentException: interface javax.persistence.EntityManagerFactory is not visible from class loader

Any help with this is very much appreciated.


Solution

  • Have you enabled JPA 2.1 on your Weblogic Instalation ?

    If you refer to :

    https://docs.oracle.com/cd/E17904_01/web.1111/e13720/using_toplink.htm#EJBAD1309

    and

    https://docs.oracle.com/middleware/1213/wls/EJBAD/using_toplink.htm#EJBAD1309

    you will note that:

    "Support for JPA 2.1 in WebLogic Server is provided as a patch because JPA 2.1 is part of the Java Platform, Enterprise Edition (Java EE) 7. Therefore, enabling JPA 2.1 support in the current release results in WebLogic Server not meeting all Java EE 6 compatibility requirements. To maintain Java EE 6 compatibility, the files required for JPA 2.1 support are not enabled by default, although they are included in a standard WebLogic Server installation."

    Have a look @

    How to Enable Java Persistence 2.0 for Weblogic 10.3.6

    and

    https://docs.oracle.com/cd/E17904_01/web.1111/e13720/using_toplink.htm#EJBAD1309