0

I'm trying execute a vaadin7 application with JPA EclipseLink. I created a folder META-INF on src/ but doesn't work and returns this error bellow:

javax.servlet.ServletException: com.vaadin.server.ServiceException:   javax.persistence.PersistenceException: No Persistence provider for EntityManager named myapp
com.vaadin.server.VaadinServlet.service(VaadinServlet.java:240)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723) 

I added all jars in Build-Path and WEB-INF/lib and my persistences.xml in src/META-INF is bellow.

<?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="myapp" transaction-type="RESOURCE_LOCAL">
      <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
      <class>com.example.testejpa.HelloWorld</class>

      <properties>
           <property name="javax.persistence.jdbc.driver" value="com.mysq.jdbc.Driver" />
           <property name="javax.persistence.jdbc.url" value="jdbc:mysql://xxx.xxx.xxx.xxx:3306/mydb" />
           <property name="javax.persistence.jdbc.user" value="user" />
           <property name="javax.persistence.jdbc.password" value="pass" />
           <property name="eclipselink.logging.level" value="FINE"/>  
    </properties>

    </persistence-unit>
</persistence> 

Any idea why this exception ?

Bhesh Gurung
  • 50,430
  • 22
  • 93
  • 142
FernandoPaiva
  • 4,410
  • 13
  • 59
  • 118
  • src/META-INF is not valid at runtime, it should be the META-INF of the jar that is added to the WEB-INF/lib. But the error message indicates that your config file is found. Which means may be either the EclipseLink jars are missing or the config file that the JPA is reading is out of date. – Bhesh Gurung Feb 19 '14 at 21:06

2 Answers2

1

The file is named persistence.xml and not persistences.xml as you did.

It has to be placed in the META-INF folder. Make sure that this folder is included in your WEB-INF folder.

From the The Java EE 6 Tutorial:

If you package the persistence unit as a set of classes in a WAR file, persistence.xml should be located in the WAR file’s WEB-INF/classes/META-INF directory.

If you package the persistence unit in a JAR file that will be included in a WAR or EAR file, the JAR file should be located in either

  • The WEB-INF/lib directory of a WAR
  • The EAR file’s library directory
nexus
  • 2,937
  • 3
  • 17
  • 22
0
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

You have a persistanceProvider

It is looking for a EntityManager Provider. The EntityManager is beeing used to persist data into a database. I guess this might be the problem and you need to add it into your persisteance.xml file.

Sembrano
  • 1,127
  • 4
  • 18
  • 28