PersistenceProvider org.hibernate.ejb.HibernatePersistence not found
I tried it... create a java class HibernateUtil.java and provide the persistence unit name to entityManagerFactory = Persistence.createEntityManagerFactory("abc");
public class HibernateUtil {
private static final EntityManagerFactory entityManagerFactory;
static {
try {
entityManagerFactory = Persistence.createEntityManagerFactory("hbPU"); // here is your persistence unit name
System.out.println("Entity Menager Test.............."+ entityManagerFactory);
} catch (Throwable ex) {
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static EntityManagerFactory getEntityManagerFactory() {
return entityManagerFactory;
}
}
and Create your persistence.xml like this
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="hbPU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<!-- map your classes. -->
<properties>
<property name="javax.persistence.jdbc.driver" value="xxx" />
<property name="javax.persistence.jdbc.url"value="xxx"/>
<property name="javax.persistence.jdbc.user" value="xxx" />
<property name="javax.persistence.jdbc.password" value="xxx" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.show_sql" value="true" />
</properties>
</persistence-unit>
</persistence>
Your Error will not come...
Sabuj Hassan
I am best with the following things: Java/J2EE with EJB, Spring, Hibernate, Eclipselink, JPA. Perl I am moderately handy with these: Scala Python Ruby PHP C/C++ I have some knowledge in: C# I can handle Application Server: Weblogic JBoss
Updated on June 04, 2022Comments
-
Sabuj Hassan almost 2 years
I am getting the following Exception while deploying my EJB EAR into
JBoss7.1
server:Caused by: javax.persistence.PersistenceException: JBAS011466: PersistenceProvider ' org.hibernate.ejb.HibernatePersistence ' not found
I have the following jar added with my EJB(These are also resides inside my jboss modules
jboss_home/modules/org/hibernate/main
):hibernate-commons-annotations-4.0.1.Final.jar hibernate-core-4.0.1.Final.jar hibernate-entitymanager-4.0.1.Final.jar hibernate-infinispan-4.0.1.Final.jar
Here is how I added hibernate provider at my
persistence.xml
file:<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0"> <persistence-unit name="hbPU" transaction-type="RESOURCE_LOCAL"> <provider> org.hibernate.ejb.HibernatePersistence </provider> ... </persistence-unit> </persistence>
-
Sabuj Hassan about 10 years
<provider>org.hibernate.ejb.HibernatePersistence</provider>
needs to be in one line. I placed it in three lines and hence it didn't work for me. Thanks :-)