After spending some time on the issue I figured out that I had to remove the DataNucleus libs from the WEB-INF/lib. I also needed to add the EclipseLink lib in my classpath. This is because I m using EclipseLink as JPA implemetation.Therefore DataNucleus were causing a conflict and thus needs to be removed. I guess that Google Plug-in for Eclipse does this automatically but apparently sometimes it fails.
Google app engine and JPA with Eclipse plug-in
-
02-12-2021 - |
Pergunta
I created an application with JSF ( Primefaces) and JPA and I m trying to deploy it on GAE. First I m trying with the local app engine sdk. I have a problem when trying to use JPA with CloudSQL. I m following the instructions on how to do it using Eclipse here:
https://developers.google.com/eclipse/docs/cloudsql-jpatools
However I get the following error:
Caused by: javax.persistence.PersistenceException: Provider error. Provider: org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider
at javax.persistence.Persistence.createFactory(Persistence.java:176)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:112)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:66)
at org.Handlers.EMFService.<clinit>(EMFService.java:8)
... 51 more
Caused by: java.lang.NullPointerException
at org.datanucleus.jpa.EntityManagerFactoryImpl.initialisePMF(EntityManagerFactoryImpl.java:452)
at org.datanucleus.jpa.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:355)
at org.datanucleus.store.appengine.jpa.DatastoreEntityManagerFactory.<init>(DatastoreEntityManagerFactory.java:63)
at org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider.createEntityManagerFactory(DatastorePersistenceProvider.java:35)
at javax.persistence.Persistence.createFactory(Persistence.java:172)
... 54 more
What s more is that I think that datanucleus is used to access the App engine Datastore. However I m trying to connect to the relational cloud sql database ( it s up and running). So i dont understand what the datanucleus has to do with that.
I m using Eclipselink for implementing the JPA spec as proposed by the following guide by GAE: https://developers.google.com/eclipse/docs/cloudsql-jpatools
Below you can also see the persistence.xml:
<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="googleeclipselink"
transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>org.entities.Department</class>
<class>org.entities.Employee</class>
<class>org.entities.Partner</class>
<class>org.entities.Project</class>
<class>org.entities.User</class>
<properties>
<!-- <property name="datanucleus.NontransactionalRead" value="true" />
<property name="datanucleus.NontransactionalWrite" value="true" /> <property
name="datanucleus.ConnectionURL" value="appengine" /> -->
<property name="javax.persistence.jdbc.driver"
value="com.google.appengine.api.rdbms.AppEngineDriver" />
<property name="javax.persistence.jdbc.url"
value="jdbc:google:rdbms://fotisgonidisseerc:googlecloudsql/researchprojects" />
<property name="javax.persistence.jdbc.user" value="" />
<property name="javax.persistence.jdbc.password" value="" />
</properties>
</persistence-unit>
</persistence>
Anybody could give me a hint of how to solve it?
Solução