users@glassfish.java.net

Re: javax.ejb.NoSuchEJBException after redeploying EJBs

From: Vetle Roeim <vetler_at_gmail.com>
Date: Thu, 13 Jan 2011 15:02:57 +0100

On Thu, Jan 13, 2011 at 09:09, Vetle Roeim <vetler_at_gmail.com> wrote:
> On Thu, Jan 13, 2011 at 00:15, Marina Vatkina <marina.vatkina_at_oracle.com> wrote:
>> See if this discussion helps:
>> http://www.java.net/forum/topic/glassfish/glassfish/redeploy-tree-0
>
> Yes, that helps. :)
>
> It makes sense, of course, but how is this commonly handled? Do I have
> to catch the exception and do a manual lookup, or is there an easier
> way to handle this?

We've found a way to solve this by wrapping the EJB and using an
InvocationHandler to look up the EJB again if calls to the EJB fails
with NoSuchEJBException. It works and we still use CDI, have a class
that @Produces the wrapped EJB reference, and automatically resort to
manual lookup if calls fail.

Regards,
Vetle