GWT with JPA - no persistence provider

GWT with JPA

There are two projects in my eclipse workspace, name them:

-JPAProject -GWTProject

JPAProject contains JPA configuration files (persistence.xml, object classes, etc.). GWTProject is a sample GWT project (taken from the official GWT tutorial).

Both projects work alone. That is, I can create an EMF (EntityManagerFactory) in JPAProject and get entities from the database. GWTProject works fine too, I can run it, fill in the text of the field in the browser and get an answer.

My goal is to call JPAProject from GWTProject to get the objects. But the problem is that when I call DAO, I get the following exception:

[WARN] Server class 'com.emergit.service.dao.profile.ProfileDaoService' could not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/home/maliniak/workspace/emergit/build/classes/' to the web app classpath for this session

[WARN] /gwttest/greet
javax.persistence.PersistenceException: No Persistence provider for EntityManager named emergitPU
    at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
    at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
    at com.emergit.service.dao.profile.JpaProfileDaoService.<init>(JpaProfileDaoService.java:19)
    at pl.maliniak.server.GreetingServiceImpl.<init>(GreetingServiceImpl.java:21)  
    ...
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
[ERROR] 500 - POST /gwttest/greet (127.0.0.1) 3812 bytes

I assume that warnings at the beginning can be omitted for now.

? , - . .


: , JPA .

, , classpath. GWT WEB-INF/lib gwt-servlet.jar.

, Ant (.. jar JPA WEB-INF/lib)? - Eclipse, GWT, GWT , persistence.xml ?

: , . persitence.xml /WEB -INF, , " ". , persistence.xml. eclipselink jar WEB-INF/lib, , persistence.xml. .

.

+5
2

, (eclipselink.jar, eclipselink-jpa-modelgen_2.1.0.v20100614-r7608.jar, javax.persistence_1.0.0jar, javax.persistence_2.0.1.v201006031150.jar) Zip EclipseLink ... /war/WEB -INF/lib GWT, Jetty . , EclipseLink 2.1. JPA.

, .

+2

, persistence.xml? - ( Hibernate , , ):

<persistence
  <persistence-unit name="emergitPU" transaction-type="...">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    ...
  </persistence-unit>
</persistence>

, , classpath. JPA webapp, .. WEB-INF/lib?

0

All Articles