0

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>
Matt Ball
  • 354,903
  • 100
  • 647
  • 710
Amson
  • 74
  • 8
  • there is one thing which i don't i would be very helpful that i'm having this warn in my persistence.xml "No grammar constraints (DTD or XML schema) detected for the document." – Amson Dec 05 '11 at 21:55
  • http://stackoverflow.com/questions/3739387/javax-persistence-persistenceexception-no-persistence-provider-for-entitymanage - this might help? In particular the namespace declaration. – Squiggs. Dec 05 '11 at 21:59
  • ir helped somehow i managed to fiw lo4j warn by adding the propertie file so i can find my problem thanks for answering – Amson Dec 05 '11 at 22:19

1 Answers1

0

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

ayengin
  • 1,606
  • 1
  • 22
  • 47