Error instantiating Persistence Provider class java.lang.ClassNotFoundException: org.hibernate.ejb.HibernatePersistence

烈酒焚心 提交于 2019-12-11 18:26:48

问题


On deploying EJB application on Weblogic : 12.2.1 , I am facing the exception :

"Error instantiating the Persistence Provider class org.hibernate.ejb.HibernatePersistence of the PersistenceUnit entityManager: java.lang.ClassNotFoundException: org.hibernate.ejb.HibernatePersistence"

I have the below configuration in persistence.xml to specify persistence provider

<persistence-unit name="entityManager">
    <!-- Use Hibernate persistency -->  
    <provider>org.hibernate.ejb.HibernatePersistence</provider>

and below in weblogic-application.xml

<prefer-application-packages>
    <package-name>antlr.*</package-name>
    <package-name>javax.persistence.*</package-name>
</prefer-application-packages>

I followed the below link to check default persistence provider set in WL , which is TopLink.

https://docs.oracle.com/middleware/1213/wls/WLACH/taskhelp/domainconfig/ConfigureDefaultJPAProvider.html

Also , tried to set classpath valriables in setDomainEnv.cmd with hibernate-jpa-api.jar, slf4j-api.jar by below configuration and restarted server .Still facing same issue.

set EXT_PRE_CLASSPATH=C:\Projects\...\lib\hibernate\hibernate-jpa-api.jar;C:\Projects\...\lib\hibernate\slf4j-api.jar

回答1:


Adding the hibernate jars to the lib folder of weblogic domain can work ie hibernate.jar , hibernate-api.jar , javax.persistence.jar, com.oracle.jpa2support_ ar and the one's you set in the classpath of setDomainEnv.cmd

Source : -https://docs.oracle.com/cd/E12839_01/web.1111/e13706/classloading.htm#WLPRG324 and https://community.oracle.com/thread/1065416



来源:https://stackoverflow.com/questions/50356492/error-instantiating-persistence-provider-class-java-lang-classnotfoundexception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!