Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Calling method on Stateful bean from another statefull bean

843829Oct 3 2001 — edited Oct 4 2001
Hi 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 1 2001
Added on Oct 3 2001
3 comments
159 views