2
You can help me with this mistake?
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.
Follow my persistence.xml
and the project folders 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>
This is the class I’m using to generate the tables in the database and it’s when you give the error:
public class HibernateSchemaGeneration {
public static void main(String[] args) throws MappingException, IOException {
Persistence.createEntityManagerFactory("bsewebservicePU");
}
}
The
persistence.xml
is inside the foldersrc/main/java/META-INF
?– Victor Stafusa
What’s in your class
br.com.brbsemanager.util.HibernateSchemaGeneration
?– Victor Stafusa
Your
persistence.xml
needs to be inside the foldersrc/main/resources/META-INF
, currently, it seems, is insrc/main/java/META-INF
.– Victor T.
I moved the Meta-inf folder to src/main/Resources/META-INF and added it to classpath, but the error continues. Before it was in src/main/java/.
– Ralkins
Victor I posted the content of the class in the question. Thank you.
– Ralkins
Did you notice that almost all packages contain errors? I think there may be some lib missing, how do you tell us which error they say ?
– Dilnei Cunha
Dilneicunha errors were pq in the classes had the Notation @Component of spring that I am no longer using. I already removed it and the errors, only errors remained in the entities, because the project is connected with the bank conection and the eclipse is seeing that the tables do not exist yet. The rest is without error.
– Ralkins
right, but what it says in this error of the entities?
– Dilnei Cunha
Dilnei, the error is in the Annotation @Entity and says: Table XXX can not be resolved.
– Ralkins
right, if the import is correct, this is a validation bug, if you disable the validations the error is missing, the application is already compiling normally? run from the same above mentioned persistence error ?
– Dilnei Cunha
Dilnei disabled the validation and the eclipse error in Annotation is gone, but even so when I run this class I posted the error remains. I am running as Javaaplication and not on the webserver.
– Ralkins
blz Manu, then this almost there, by what I saw you just created the factory and did nothing else, not even returned to an Entitymanagerfactory emf; after creating the factory do: Entitymanager em = emf.createEntityManager(); then it is give new in the popular obejto and do in.persist(object) do not forget that you have to open the trasaction to save, when working standalone need to do everything at hand.
– Dilnei Cunha