users@glassfish.java.net

Re: No META-INF/persistence.xml was found in classpath.

From: Rochelle Raccah <Rochelle.Raccah_at_Sun.COM>
Date: Wed, 09 Jul 2008 10:28:55 -0700

At the risk of pointing out something obvious -- your post listed the
name of your file as persistance.xml twice. Glassfish is looking for
persistence.xml (note the spelling of the name of the file). Perhaps
that is the problem?

Rochelle

glassfish_at_javadesktop.org wrote:
> I am trying to run the glassFish java persistance example for Java SE. I am not able to run the example and I am getting the following error:
>
> Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named pu1: No META-INF/persistence.xml was found in classpath.
>
> at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:154)
> at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
> at client.Client.main(Client.java:45)
>
> My persistance.xml file is as follows:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
> <persistence-unit name="pu1">
> <provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
> <class>entity.Customer</class>
> <class>entity.Order</class>
> <properties>
> <property name="toplink.jdbc.driver" value="com.mysql.jdbc.Driver"/>
> <property name="toplink.jdbc.url" value="jdbc:mysql://localhost:3306/chela"/>
> <property name="toplink.jdbc.user" value="root"/>
> <property name="toplink.jdbc.password" value="root"/>
> <property name="toplink.logging.level" value="INFO"/>
> </properties>
> </persistence-unit>
> </persistence>
>
> I created a new java project in eclipse and created the packages for client and entity and copied the java source file from the example. I created a new folder(META-INF) and copied the persistance.xml file into that folder.
>
> My project directory structure:
>
> my project
> |
> client
> | |
> | Client.java
> |
> entity
> | |
> | Customer.java
> | Order.java
> |
> META-INF
> persistance.xml
>
> I also added the glassfish jar files and mysql jar files to the project libraries by right clicking on the eclipse project/properties and the Library tab.
>
> But I am not able to get it running and getting the above error. Any help would be appreciated. I am not sure how to add the META-INF/persistance.xml file to the classpath.
> [Message sent by forum member 'sensel' (sensel)]
>
> http://forums.java.net/jive/thread.jspa?messageID=285270
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>