File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes New EJB Instance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "New EJB Instance" Watch "New EJB Instance" New topic

New EJB Instance

Jeff Storey
Ranch Hand

Joined: Oct 09, 2006
Posts: 118
Hi everyone. I have a problem where I'm trying to get a new instance of a stateful bean. The situation is that I have Bean A doing some processing that I want to cancel. Rather than trying to stop it in its tracks, I simply give the client program a new copy of that bean, call it Bean B. The client now listens to messages sent from Bean B, and is unaware that Bean A is still finishing its server side processing (at which point it will no longer be used).

I try to lookup the bean with
Object ref = jndiContext.look("MyBeanClassImpl/remote");
MyBeanClass b = (MyBeanClass) PortableRemoteObject.narrow(ref,MyBeanClass.class)

When I do an == comparison on Bean A and Bean B, it returns true and then I get errors about concurrent calls on the bean. Essentially, the users reference to the MyBeanClass object should now be pointing to B, which should be different than A. Can someone explain to me why it is not different and how I can make it be different?

Thank you,
Jeff Storey
Ranch Hand

Joined: Oct 09, 2006
Posts: 118
I realized this was NOT what was happening and the problem was elsewhere - problem solved.
I agree. Here's the link:
subject: New EJB Instance
It's not a secret anymore!