As Google presented new service – Google Cloud Sql, I decided to migrate gwt+jpa+hibernate+spring+maven web application to gae.
So I have a problem while starting my app locally and on gae.
I have an error creating dao bean caused by this:
[ERROR] Caused by: java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode;
[ERROR] at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:625)
[ERROR] at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
[ERROR] at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
[ERROR] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310)
[ERROR] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
[ERROR] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
So it seemed to me, that I was using jpa-1.0 instead of jpa-2.0 with hibernate (cause jpa 1.0 lacks of method:
getValidationMode()
I checked my libs…everthing is ok – using jpa 2.0 with hibernate-jpa-2.0-api.jar.
But I found a promlem:
When I use my code without gae and I use another db everthing is ok. The fact is that appengine sdk include its own JPA and the version is 1.0 (quote from here Using JPA with App Engine)
The JPA and datastore JARs are included with the App Engine Java SDK. You can find them in the appengine-java-sdk/lib/user/orm/ directory.
Copy the JARs to your application’s war/WEB-INF/lib/ directory.
When an application starts, it use jpa 1.0(with no method getValidationMode() in javax.persistence.spi.PersistenceUnitInfo) from appengine sdk instead of mine.
So, how can I come over this problem to make my app use right jars?
Here is my persistence.xml also:
<?xml version="1.0" encoding="UTF-8"?>
<persistence 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"
version="2.0">
<!-- A JPA Persistence Unit -->
<persistence-unit name="PersistenceUnit"
transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.connection.url" value="jdbc:google:rdbms://bragininim:test/test"></property>
<property name="hibernate.connection.driver_class"
value="com.google.appengine.api.rdbms.AppEngineDriver"></property>
<!-- Connection -->
<property name="hibernate.connection.username" value="****" />
<property name="hibernate.connection.password" value="****" />
</properties>
</persistence-unit>
</persistence>
There is some issue with Hibernate JPA support, because it used JPA 2.0 specification. But Google App Engine only support JPA1.0 specification. I also had same issue, there for I used Spring Hibernate support(instead of Hibernate JPA).
For your problem also I think better to use Spring Hibernate support.