Calling method on Stateful bean from another statefull bean
843829Oct 3 2001 — edited Oct 4 2001Hi all,
I have a stateful session bean (LoginBean) that is used to create connections for various databases. This bean has methods to create the connections and to return the connections.
I then have another stateful that needs to call the getConnection method on the Login bean. My question is how do I obtain a reference to the already instantiated Login bean.
I know that the Login bean is instantiated because the first thing the client does is create it.
I tried the following code to get a reference to the LoginBean
-------------------
javax.naming.Context context = new javax.naming.InitialContext();
Object ref;
//look up jndi name
ref = context.lookup("LoginBean");
loginHome = (LoginHome) PortableRemoteObject.narrow(ref, LoginHome.class);
login = loginHome.create();
-------------------
The above code works but it does not give me the instantiated instance that has already been set up by the client, instead i get an new instance.
Am I doing something horribly wrong?
Any help would be grateful as this is the first time that I am trying this.
Ricardo