users@glassfish.java.net

[gf-users] Re: Future get() method behavior

From: Dennis Gesker <dennis_at_gesker.com>
Date: Mon, 11 Aug 2014 13:22:47 -0600

Laird:

You are exactly right. My get() calls a Future<Integer> method decorated
with @Asynchronous which actually returns AsyncResult() from a SessionBean.

But, I am injecting the SessionBean with @Inject. l also tried changing
@Inject to @EJB just to beat a dead horse.

Anything else you think I might try?

Dennis
btw -- thanks for the link on merge


On Mon, Aug 11, 2014 at 11:36 AM, Laird Nelson <ljnelson_at_gmail.com> wrote:

> On Mon, Aug 11, 2014 at 9:25 AM, Dennis Gesker <dennis_at_gesker.com> wrote:
>
>> Yes. That's the rub. It doesn't.
>>
>
> I'm not entirely sure what's going on either, but by any chance is the
> Future you're calling get() on an instance of AsyncResult (
> http://docs.oracle.com/javaee/7/api/javax/ejb/AsyncResult.html)? Let's
> start there. My thinking would be that somewhere in your code you're
> invoking an asynchronous EJB method without going through an EJB proxy
> first (that is, pullProjectBudget was not injected via @EJB or @Inject
> but directly constructed by you), and so the Future you're being handed
> isn't really a Future in all the important ways (since AsyncResult#get()
> just returns whatever it was built with immediately), and so might be
> behaving oddly from your point of view. This is a bit of a sketchy theory
> but it's all I can think off offhand.
>
> I noticed (on a different subject) that there's a lot of extraneous usage
> of EntityManager#merge() and possibly flush() in the pastebin code as
> well; you may want to read up on exactly what a persistence context is.
> Hint: merge doesn't mean save. I wrote up a blog article on this some
> time ago that may be helpful:
> http://lairdnelson.wordpress.com/2013/04/04/the-bag/
>
> Best,
> Laird
>
> --
> http://about.me/lairdnelson
>



-- 
*Dennis Gesker*
<http://goog_777861789>[image: www.linkedin.com/in/gesker]
<http://www.linkedin.com/in/gesker>[image: http://www.facebook.com/gesker]
<https://www.facebook.com/gesker>[image: https://twitter.com/gesker]
<https://twitter.com/gesker>[image: http://gesker.wordpress.com]
<http://gesker.wordpress.com>[image:
https://pgp.mit.edu/pks/lookup?search=dennis%40gesker.com&op=index]
<https://pgp.mit.edu/pks/lookup?search=dennis%40gesker.com&op=index>[image:
http://www.gesker.com] <http://www.gesker.com>[image: dennis@gesker.com]
<dennis_at_gesker.com>