This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes JPA - problem with persistence.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "JPA - problem with persistence.xml" Watch "JPA - problem with persistence.xml" New topic
Author

JPA - problem with persistence.xml

Micra Micron
Greenhorn

Joined: Feb 24, 2010
Posts: 2
Hello I'm new in JPA, and trying to run a simple example.
Eclipse is telling me that something is wrong with <provider> element. Please help me to understand what exactly is wrong there.

ERROR: "Description Resource Path Location Type
cvc-complex-type.2.4.a: Invalid content was found starting with element 'provider'. One of '{"http://java.sun.com/xml/ns/persistence":class, "http://java.sun.com/xml/ns/persistence":exclude-unlisted-classes, "http://java.sun.com/xml/ns/persistence":properties}' is expected. persistence.xml /SimpleJPATest/src/META-INF line 5 XML Problem"


persistence.xml
=============
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/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_1_0.xsd">
<persistence-unit name="SimpleJPATest" transaction-type="RESOURCE_LOCAL">
<class>model.User</class>
<provider>oracle.toplink.essentials.PersistenceProvider</provider>
<properties>
<property name="toplink.logging.level" value="FINEST"/>
<property name="toplink.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"/>
<property name="toplink.jdbc.url" value="jdbc:derby://localhost:1527/sample;create=true"/>
<property name="toplink.jdbc.user" value="dali"/>
<property name="toplink.jdbc.password" value="dali"/>
</properties>
</persistence-unit>
</persistence>


Thank you in advance,
Micra.
Micra Micron
Greenhorn

Joined: Feb 24, 2010
Posts: 2
No one can advice ?
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
The order is important in the persistence.xml (and most XML files).

The schema is at,
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd

You need to put the <provider> before the <class>.

TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: JPA - problem with persistence.xml
 
Similar Threads
no error but entity is not persisted
How to use Container Managed EntityManager inside the SessionBean
How to Create Auto Schema
EclipseLink1.1 inserts no data..
'hibernate.dialect' must be set when no Connection available