AppEngine Plugin

Can't run integration test involving JPA GORM API

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
  • Testcase included:
    yes

Description

Simple integration test involving the gorm-jpa API get. Test fails with following exception :

No API environment is registered for this thread.
java.lang.NullPointerException: No API environment is registered for this thread.
	at com.google.appengine.api.datastore.DatastoreApiHelper.getCurrentAppId(DatastoreApiHelper.java:67)
	at com.google.appengine.api.datastore.DatastoreApiHelper.getCurrentAppIdNamespace(DatastoreApiHelper.java:77)
	at com.google.appengine.api.datastore.Key.<init>(Key.java:103)
	at com.google.appengine.api.datastore.Key.<init>(Key.java:88)
	at com.google.appengine.api.datastore.KeyFactory.createKey(KeyFactory.java:46)
	at com.google.appengine.api.datastore.KeyFactory.createKey(KeyFactory.java:31)
	at org.datanucleus.store.appengine.EntityUtils.intOrLongToInternalKey(EntityUtils.java:260)
	at org.datanucleus.store.appengine.EntityUtils.idToInternalKey(EntityUtils.java:136)
	at org.datanucleus.store.appengine.EntityUtils.idToInternalKey(EntityUtils.java:124)
	at org.datanucleus.store.appengine.jpa.DatastoreEntityManager.find(DatastoreEntityManager.java:52)
	at org.grails.jpa.JpaPluginSupport$__clinit__closure3_closure7_closure12_closure20.doCall(JpaPluginSupport.groovy:270)
	at my.MyEntityTests.testGetFirst(MyEntityTests.groovy:20)
	at junit.framework.Test$run.call(Unknown Source)

Activity

Hide
Sebastien Pouillet added a comment -

From the test case, execute :

grails test-app integration: MyEntity

and have a look at the test reports.

Thanks

Show
Sebastien Pouillet added a comment - From the test case, execute :
grails test-app integration: MyEntity
and have a look at the test reports. Thanks
Hide
Dirk Jäckel added a comment -

I have the same problem. Is this only a problem in combination with the AppEngineGrailsPlugin?

Is there a workaround?

I'd really love to use integration tests with grails gorm-jpa and GAE.

Show
Dirk Jäckel added a comment - I have the same problem. Is this only a problem in combination with the AppEngineGrailsPlugin? Is there a workaround? I'd really love to use integration tests with grails gorm-jpa and GAE.
Hide
Dirk Jäckel added a comment -

I am using Objectify now as my persistence layer. How can I remove all JPA and JDO from my grails project? Would that also remove the error above?

Show
Dirk Jäckel added a comment - I am using Objectify now as my persistence layer. How can I remove all JPA and JDO from my grails project? Would that also remove the error above?
Hide
Tom Hsu added a comment -

I have gotten the same error as well with a very simple User domain and UserIntegrationTest. the error in report is:

Could not open JPA EntityManager for transaction; nested exception is java.lang.NullPointerException: No API environment is registered for this thread.

org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is java.lang.NullPointerException: No API environment is registered for this thread.
Caused by: java.lang.NullPointerException: No API environment is registered for this thread.
at com.google.appengine.api.datastore.DatastoreApiHelper.getCurrentAppId(DatastoreApiHelper.java:108)
at com.google.appengine.api.datastore.BaseDatastoreService.beginTransaction(BaseDatastoreService.java:125)
at org.datanucleus.store.appengine.RuntimeExceptionWrappingDatastoreService.beginTransaction(RuntimeExceptionWrappingDatastoreService.java:209)
at org.datanucleus.store.appengine.jpa.DatastoreEntityTransactionImpl.begin(DatastoreEntityTransactionImpl.java:49)
at _GrailsTest_groovy$_run_closure4.doCall(_GrailsTest_groovy:269)

Any workaround available?

Show
Tom Hsu added a comment - I have gotten the same error as well with a very simple User domain and UserIntegrationTest. the error in report is: Could not open JPA EntityManager for transaction; nested exception is java.lang.NullPointerException: No API environment is registered for this thread. org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is java.lang.NullPointerException: No API environment is registered for this thread. Caused by: java.lang.NullPointerException: No API environment is registered for this thread. at com.google.appengine.api.datastore.DatastoreApiHelper.getCurrentAppId(DatastoreApiHelper.java:108) at com.google.appengine.api.datastore.BaseDatastoreService.beginTransaction(BaseDatastoreService.java:125) at org.datanucleus.store.appengine.RuntimeExceptionWrappingDatastoreService.beginTransaction(RuntimeExceptionWrappingDatastoreService.java:209) at org.datanucleus.store.appengine.jpa.DatastoreEntityTransactionImpl.begin(DatastoreEntityTransactionImpl.java:49) at _GrailsTest_groovy$_run_closure4.doCall(_GrailsTest_groovy:269) Any workaround available?

People

Vote (4)
Watch (4)

Dates

  • Created:
    Updated: