Reputation: 74
i have this project where i'm using hibernate, JPA, Tomcat, and JSF. Anyway i have been trying to solve this error for over two hours with no success. all my jars are included but this error don't want to give me a beak. this is my error:
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named examplePersistenceUnit
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:56)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34)
at test.TestBase.<init>(TestBase.java:15)
at test.TestCandidat.<init>(TestCandidat.java:14)
at test.TestCandidat.main(TestCandidat.java:83)
This is my persistence.xml:
<?xml version="1.0"
encoding="UTF-8"?>
<persistence>
<persistence-unit name="examplePersistenceUnit"
transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value="false" />
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/RecrutementDB" />
<property name="hibernate.connection.username" value="root" />
<property name="hibernate.connection.password" value="3031989" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.hbm2ddl.auto" value="create" />
</properties>
</persistence-unit>
</persistence>
Upvotes: 0
Views: 902
Reputation: 1596
First add log4j.properties file under WEB-INF and make sure persistence.xml under META-INF folder .If not help you probably have a syntax error in persistence.xml
Upvotes: 0