Reputation: 671
Executing a Java SE JPA standalone application throws the exception:
javax.persistence.PersistenceException: No Persistence provider for EntityManager named test
I have found several similar posts but I think that none of them applies to my case with EclipseLink, Java SE and no packaging into deployable files and hence no WEB-INF etc.
The /src/META-INF/persistence.xml is:
<persistence>
<persistence-unit name="test" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>SomeEntity</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/somedbname"/>
<property name="javax.persistence.jdbc.user" value="foo"/>
<property name="javax.persistence.jdbc.password" value="bar"/>
</properties>
</persistence-unit>
</persistence>
The following jars are on the build path:
Upvotes: 0
Views: 656
Reputation: 671
I had to provide the persistence namespace in persistence.xml with the xmlns attribute
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
Upvotes: 1
Reputation: 1858
You have to add the eclipselink jar to your ClassPath to check is it's already there or no:
System.out.println(System.getProperty("java.class.path"));
Upvotes: 0