JPA cannot find persistence provider

Hi,
I'm using IntelliJ IDEA 9 M1 in Mac OS for a project with JPA persistence.
It's compiled without any problem but running the program cause the following error.

javax.persistence.PersistenceException: No Persistence provider for EntityManager named agisdb-PU
     at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:89)
     at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:60)
     at com.agis.livedb.domain.util.PersistenceUtil.getAgisDbEntityManager(PersistenceUtil.java:22)

Here is the persistence.xml I have

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
    <persistence-unit name="agisdb-PU">
        <class>com.agis.livedb.domain.AddressEntity</class>
        <properties>
            <property name="toplink.jdbc.url" value="jdbc:mysql://localhost:3306/agisdb"/>
            <property name="toplink.jdbc.driver" value="com.mysql.jdbc.Driver"/>
            <property name="toplink.jdbc.user" value="root"/>
            <property name="toplink.jdbc.password" value="password"/>
        </properties>
    </persistence-unit>
</persistence>

And below is how I get the entity manager factory...

EntityManagerFactory emfdb = Persistence.createEntityManagerFactory("agisdb-PU");



I have already checked the classpath shown when I run the application, and it has already included the compilation output directory. And I have verified that the persistence.xml is inside the META-INF directory under that directory.

Is there any additional setting I need to add?
Thank you,
Robert

2 comments
Comment actions Permalink

That's an JPA question rather than an IDEA question, but anyway:
My persistence.xml explicitly specifies the provider in a tag directly nested inside the <persistence-unit> tag:
<provider>org.hibernate.ejb.HibernatePersistence</provider>

If you are not using Hibernate, but have correctly added the jar file containing the provider in IDEA, then you can probably quickly find out the correct classname for your provider by
ctrl-n, PersistenceProvider (that should take you to the interface)
then ctrl-alt-b which should go to the implementation class of your provider.

0
Comment actions Permalink

Hi, thanks Stephen! I got to find the persistenceprovider and put it in the library.
Thanks!
Robert

0

Please sign in to leave a comment.