0
votes

I am trying to get eclipselink working with GWT's requestfactory. I keep getting the following error:

Caused by: java.lang.RuntimeException: Server Error: No Persistence provider for EntityManager named default 

Reading around the web, it seems that persistence.xml must live in WEB-INF/classes/META-INF/. I tried creating a folder under src/META-INF and placing persistence.xml in it, but it does not get included in war/WEB-INF/classes/ when I build the project in eclipse. Any suggestions? I am using GWT 2.3, EclipseLink 2.3, and eclipse 3.7. How can I get eclipse to include persistence.xml into the right location?

persistence.xml

<?xml version="1.0" encoding="UTF-8" ?> <persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">

<persistence-unit name="default" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

    <class>com.manning.gwtia.ch08.v2.server.Contact</class> 

    <properties>
        <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
        <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/example" />
        <property name="javax.persistence.jdbc.user" value="" />
        <property name="javax.persistence.jdbc.password" value="" />

        <!-- EclipseLink should create the database schema automatically -->
        <property name="eclipselink.ddl-generation" value="create-tables" />
        <property name="eclipselink.ddl-generation.output-mode" value="database" />
    </properties>

</persistence-unit>

1

1 Answers

2
votes

Did you try placing the persistence.xml in the folderwar/META-INF?

EDIT: Other option: The reason you persistence.xml was not copied from the src/META-INF folder to the classes folder could be because your eclipse java build path configuration only includes specific type of files to be copied to the classes folder. Check your project properties -> Java Build Path -> Source and check what is under included/excluded. This might explain.