users@glassfish.java.net

Re: No Persistence provider for EntityManager!!!!

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Fri, 12 Jun 2009 10:41:09 -0700

You might want to read the corresponding chapters in the Java EE 5 Tutorial.

I think you are mixing 2 setups - your persistence.xml specifies the datasource,
i.e. you are running in a environment where you can do a lookup. Is it true? If
yes, you should be looking up the EntityManagerFactory, not creating it yourself.

How does the EnterpriseApplication1-war refer to the EnterpriseApplication1-ejb?
Where is the persistence.xml located?

Regards,
-marina

glassfish_at_javadesktop.org wrote:
> Sorry I don't understand. To recap, what I have done is as follows;
> [b]1. netbeans project [/b]
> I have created a netbeans Enterprise Application that consists of the following;
> a. EnterpriseApplication1-ejb : Contains an Entity class called Products and a DBAO to access a mySQL database
> b. EnterpriseApplication1-war : Contains a Web Service that calls logic contained in a.)
>
> In terms of classpath, I have the following setup;
> .;%JAVA_HOME%\bin;%JRE_HOME\bin;C:\Program Files\Java\jre6\lib\ext\QTJava.zip;C:\Program Files\NetBeans 6.5\java2\modules\ext\hibernate;
>
> [b]2. Persistence.xml [/b]
> The persistence.xml file looks as follows;
>
> <persistence-unit name="productsPU">
> <jta-data-source>depotDB</jta-data-source>
> <class>org.rich.entities.Products</class>
> <exclude-unlisted-classes>true</exclude-unlisted-classes>
> <properties/>
> </persistence-unit>
>
> depotDB refers to a data source that accesses a mySQL database. When I go under the covers in netbeans, persistence.xml seems to be in the right place.
>
> [b]3. DBAO Products[/b]
> In my database access class, I have the following code
>
> EntityManagerFactory emf = Persistence.createEntityManagerFactory("productsPU");
>
> EntityManager em = emf.createEntityManager();
>
> [b]4. The Result[/b]
> When I run the application, I get the following;
>
> Caused by: javax.persistence.PersistenceException: No Persistence provider for EntityManager named productsPU: The following providers:
> oracle.toplink.essentials.PersistenceProvider
> oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider
> Returned null to createEntityManagerFactory.
>
>
> As I am relatively new to using netbeans, glassfish and the JPA, I have absolutely no idea what is going on. Sadly, I've spent about 8 hours trying to debug to no avail.
>
> Any pointers would be much appreciated.
> [Message sent by forum member 'rwwebb' (rwwebb)]
>
> http://forums.java.net/jive/thread.jspa?messageID=350865
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>