EclipseLink: Continuous Sustainability Provider for EntityManager

I am trying to develop a web application. I started creating Play! Framework project in Eclipse. For part of the model, I decided to use JPA, and since I had already created the database, I was looking for a way to automatically generate model classes. I converted it to a faceted form and used Dali to create a mapping to the database. During the configuration, I was fortunate enough to choose a JPA implementation, so I chose EclipseLink 2.1.3 Helios as the user library. All banks added to my project. After searching for such errors, I changed the persistence.xml file to:

<?xml version="1.0" encoding="UTF-8"?> <persistence version="2.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_2_0.xsd"> <persistence-unit name="StudentApplication"> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> <class>models.Grade</class> <class>models.GradePK</class> <class>models.Student</class> <properties> <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/studentapplication"/> <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/> <property name="javax.persistence.jdbc.user" value="root"/> <property name="javax.persistence.jdbc.password" value="root"/> </properties> </persistence-unit> </persistence> 

The exact error I'm getting now: Execution exception (In / app / controllers / class.java line 98) PersistenceException: there is no Persistence provider for EntityManager named jpa

I should note that in application.conf I declared a db connection, and when I run the application, I get

22: 03: 53,084 INFO ~ Connected to jdbc: mysql: // localhost / studentapplication? useUnicode = yes & characterEncoding = UTF-8 & connectionCollation = utf8_general_ci

Finally, the file structure:

-controllers
models
View
M- INF
| _persistense.xml

As you may have understood (besides my representative), I am new to web application development and, in particular, to JPA. I would be more than grateful for any help. I apologize in advance if I posted the necessary information or if I missed the required information. Thank you for your time.

Thomas

+4
source share
1 answer

It seems that you are referring to the persistence block in your application under a different name than in your persistence.xml. Your persistence unit is called StudentApplication in the persistence.xml file. However, the error indicates that it is called "jpa" in your application.

Assuming you are using an application-driven entity manager, your application should have this line:

 EntityManagerFactory emf = Persistence.createEntityManagerFactory("jpa"); 

Change it to

 EntityManagerFactory emf = Persistence.createEntityManagerFactory("StudentApplication"); 
+4
source

Source: https://habr.com/ru/post/1400764/


All Articles