playframework - future.get does not work using java future/promise -


i have making senddate async using future

executorservice es = executors.newfixedthreadpool(3); final future<string> future = es.submit(new callable<string>() {     public string call() throws exception {           // send data return string         return senddata(jobject.tostring(), "delivery", act_id);     } }); system.out.println("\n\n\n\n\n\n\n no future!" + future.get());  //then tried call here 

but got error

java.lang.runtimeexception: no entitymanager bound thread. try wrapping call in jpa.withtransaction, or ensure http context setup on thread. 

i'm new use promise/future , don't know how solve it.

it says need in error message :-)

wrap call senddata method jpa.withtransaction call. :

jpa.withtransaction(new play.libs.f.function0<string>() {     public string apply() {                return senddata(jobject.tostring(), "delivery", act_id);     } }); 

alternatively can try bind entitymanager current thread using threadlocal.


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -