How to solve the JPA Hibernate error

1

Can you help me with this error?

Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named bsewebservicePU
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:61)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
    at br.com.brbsemanager.util.HibernateSchemaGeneration.main(HibernateSchemaGeneration.java:23)

I've done everything in the project to try to run, but nothing worked.

Here are my persistence.xml and the project folder tree:

<persistence-unit name="bsewebservicePU" transaction-type ="RESOURCE_LOCAL">

    <provider>org.hibernate.ejb.HibernatePersistence</provider>

    <class>br.com.bsemanager.domain.Entidades.Cliente</class>
    <class>br.com.bsemanager.domain.Entidades.Emprestimo</class>
    <class>br.com.bsemanager.domain.Entidades.Endereco</class>
    <class>br.com.bsemanager.domain.Entidades.Operador</class>

    <properties>
        <property name="javax.persistence.jdbc.url" 
        value="jdbc:mysql://localhost:3306/bsemanager"/>

        <property name="javax.persistence.jdbc.user" 
        value="root"/>

        <property name="javax.persistence.jdbc.password" 
        value="root"/>

        <property name="javax.persistence.jdbc.driver" 
        value="com.mysql.jdbc.Driver"/>

        <property name="hibernate.dialect" 
        value="org.hibernate.dialect.MySQL5Dialect"/>

        <property name="hibernate.show_sql" value="true" />
        <property name="hibernate.format_sql" value="true" />
        <property name="hibernate.hbm2ddl.auto" value="update" />
    </properties>
</persistence-unit>

ThisistheclassIamusingtogeneratethetablesinthedatabaseanditiswhentheerroroccurs:

publicclassHibernateSchemaGeneration{publicstaticvoidmain(String[]args)throwsMappingException,IOException{Persistence.createEntityManagerFactory("bsewebservicePU");
    }
}
    
asked by anonymous 22.08.2016 / 18:01

2 answers

2

Hi, you are using the EclipseLink 2.5.2 library in your classpath, but in your persistence.xml says that your implementation is from Hibernate ...

Ex:

<provider>org.hibernate.ejb.HibernatePersistence</provider>

Answer: you should change the EclipseLink 2.5.2 library to one of hibernate in your classpath. Access and download a library with a version compatible with your application link

ps: The errors flagged in your project should be incompatible with EclipseLink library imports.

    
25.08.2016 / 19:27
0

If the bundle and jars in use are Hibernate version 5.2.2, I think maybe my answer below is that I posted another question ... I'll just paste it down ... But basically, in this new version, I do not comes the org.hibernate.ejb.HibernatePersistence class, I do not know if it was deprecated or if they just retired. I had to use the org.hibernate.jpa.HibernatePersistenceProvider class as the provider in persistence.xml and, at least for me, it worked.

The org.hibernate.ejb.HibernatePersistence class does not exist in the hibernate-release-5.2.2.Final.zip bundle file. That's why the provider can not be found, because the class can not (at the project library jars). Instead, I used the class org.hibernate.jpa.HibernatePersistenceProvider , which CAN
10.09.2016 / 10:33