users@glassfish.java.net

Re: hot-deploy of EJB causes NoSuchEJBException in Servlet

From: Marina Vatkina <marina.vatkina_at_oracle.com>
Date: Wed, 16 Mar 2011 11:32:46 -0700

Martin,

EJB Container injects a proxy into the @EJB ref that allows to find the
actual bean by its id. The id changes on redeploy (unless redeploy uses
--keepstate=true but it adds some restrictions on the allowed changes
for the application being redeployed).

You either need to replace injection with a lookup or add a method that
does the lookup only when access of the ref fails.

HTH,
-marina

forums_at_java.net wrote:
> Hi,
> I'm currently having a try with EJB 3.1 and Glassfish 3.1 in Eclipse.
>
> This is what my project looks like:
> - one EJB project (@Singleton) and one Utility Module project with the
> bean's remote interface (@Remote)
> - one ear that contains the EJB
> - one war with a servlet that uses the beans remote interface (@EJB
> annotation)
>
> I have deployes ear and war to the glassfish using the eclipse
> integration
> and everything works fine.
> When I change anything in the ejb's implementation (e.g. changing the
> console
> output done in a method that is called by the servlet) and try to call
> the
> EJB again from the servlet, I get a NoSuchEJBException.
> I can workarround this by using the initial context and doing a lookup
> for
> the bean everytime I want to use it. Additionally I found this post that
> proposes another solution
> (http://stackoverflow.com/questions/4667410/javax-ejb-nosuchejbexception-after-redeploying-ejbs/4678040#4678040
>
> [1])
>
> Nevertheless, I wonder why it behaves like this. The server seems to
> now that
> the old ejb is no longer existing. So why doesn't he just do a lookup
> for a
> new one?!
>
> Regards, Martin
>
>
> [1]
> http://stackoverflow.com/questions/4667410/javax-ejb-nosuchejbexception-after-redeploying-ejbs/4678040#4678040
>
>
> --
>
> [Message sent by forum member 'm.wahnschaffe']
>
> View Post: http://forums.java.net/node/782092
>
>