Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7760701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:57:32+00:00 2026-06-01T13:57:32+00:00

I would like to test my JDO – DAO with multiple threads in order

  • 0

I would like to test my JDO – DAO with multiple threads in order to verify if the persistence layer is aware of synchronization.

Here is my piece of code in a JUnit test

for(int i=0;i<10;i++) {
    Runnable runnable = new UserAccountLifeCycle(..);
    Thread thread = new Thread(runnable);
    thread.start();
}

.. where UserAccountLifeCycle is a class that extends another business layer class and implements “Runnable” with this code:

@Override
public void run() {
    CategoryBusiness catBusiness = new CategoryBusiness(..);
    Category cat1 = catBusiness.createEntity(..);
    catBusiness.createEntities(..);
    ContentBusiness conBusiness = new ContentBusiness(..);
    conBusiness.createEntities(..);
}

If I run the test I get:

Exception in thread “Thread-6” java.lang.NullPointerException: No API
environment is registered for this thread. at
com.google.appengine.api.datastore.DatastoreApiHelper.getCurrentAppId(DatastoreApiHelper.java:86)
at
com.google.appengine.api.datastore.DatastoreAttributes.(DatastoreAttributes.java:28)
at
com.google.appengine.api.datastore.AsyncDatastoreServiceImpl.getDatastoreAttributes(AsyncDatastoreServiceImpl.java:952)
at
com.google.appengine.api.datastore.AsyncDatastoreServiceImpl.getDatastoreType(AsyncDatastoreServiceImpl.java:944)
at
com.google.appengine.api.datastore.AsyncDatastoreServiceImpl.get(AsyncDatastoreServiceImpl.java:267)
at
com.google.appengine.api.datastore.DatastoreServiceImpl$1.runInternal(DatastoreServiceImpl.java:78)
at
com.google.appengine.api.datastore.DatastoreServiceImpl$1.runInternal(DatastoreServiceImpl.java:75)
at
com.google.appengine.api.datastore.TransactionRunner.runInTransaction(TransactionRunner.java:31)
at
com.google.appengine.api.datastore.DatastoreServiceImpl.get(DatastoreServiceImpl.java:75)
at
com.google.appengine.api.datastore.DatastoreServiceImpl.get(DatastoreServiceImpl.java:62)
at
org.datanucleus.store.appengine.RuntimeExceptionWrappingDatastoreService.get(RuntimeExceptionWrappingDatastoreService.java:56)
at
org.datanucleus.store.appengine.DatastorePersistenceHandler.get(DatastorePersistenceHandler.java:100)
at
org.datanucleus.store.appengine.DatastorePersistenceHandler.get(DatastorePersistenceHandler.java:112)
at
org.datanucleus.store.appengine.DatastorePersistenceHandler.fetchObject(DatastorePersistenceHandler.java:517)
at
org.datanucleus.state.JDOStateManagerImpl.validate(JDOStateManagerImpl.java:4263)
at
org.datanucleus.ObjectManagerImpl.findObject(ObjectManagerImpl.java:2444)
at
org.datanucleus.jdo.JDOPersistenceManager.getObjectById(JDOPersistenceManager.java:1671)
at
org.datanucleus.jdo.JDOPersistenceManager.getObjectById(JDOPersistenceManager.java:1767)
at
org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManager.getObjectById(DatastoreJDOPersistenceManager.java:73)
at
it.icaroproject.main.persistence.dao.GaedatastoreUserAccountDAO.addCategories(GaedatastoreUserAccountDAO.java:174)
at
it.icaroproject.main.business.CategoryBusiness.createEntities(CategoryBusiness.java:83)
at
it.icaroproject.main.business.CategoryBusiness.createEntity(CategoryBusiness.java:76)
at
it.icaroproject.test.business.UserAccountLifeCycle.run(UserAccountLifeCycle.java:52)
at java.lang.Thread.run(Thread.java:680)

If I run this code works:

for(int i=0;i<10;i++) {
    UserAccountLifeCycle lifeCycle = new UserAccountLifeCycle(i,testUser.getKey());
    lifeCycle.run();
}

(I know it doesn’t run the method as a thread, but it is intended as the proof that JUnit test is configured correctly with GAE local testing)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T13:57:34+00:00Added an answer on June 1, 2026 at 1:57 pm

    Although the App Engine Java runtime supports threads, the dev_appserver doesn’t. Results from testing concurrency on the local dev environment are thus not going to be representative of the production environment.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to test a process that queries across multiple schemas using PHPUnit's
I would like to test a webpage in multiple browsers, in my local machine.
Problem I would like to test if an element of a list exists, here
I would like to test if a point is within a particular distance of
I would like to test some exception handling logic in the empty catch block
I would like to test an app that uses the Clipboard (WindowsForms) and I
I would like to test a web app that was drastically redesigned to use
I would like to do a test like: http://stevelibonati.wordpress.com/2012/02/05/spring-mvc-test-with-a-sprinkle-of-mockito/ My problem is that I
I would like to test if an instance variable lies in a range of
I've nearly finished the development of a project and would like to test its

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.