An MDB running in the Weblogic context (running on machine A) looks up a Session Bean deployed under JBoss (running on machine B). This reference (home reference) is stored in a HashMap for re-use,since JNDI lookups can be expensive. This Home Reference is used to create a remote reference.

Now, the problem I am running into:

The above mechanism works fine when I first start the WL Server,the JBoss server, and lookup the Session Bean (this is stored in the HashMap, for re-use) using JNDI (see below for code). So long as the JBossApp Server is up and running, everything works fine.

When I bounce the JBoss App Server, and try to use the SessionBean Home reference (stored in the HashMap) to create a remote reference,I get a java.rmi.NoSuchObjectException -- which is understandable, since the JBoss App Server is bounced.

After I catch the java.rmi.NoSuchObjectException, I am trying to lookup the Session Bean deployed under Jboss (using the same piece of code that I used initially to perform the lookup) from the MDB running in Weblogic context, and all I get is a 'null' object. NO EXCEPTIONS ARE THROWN EITHER. Until I bouncethe Weblogic Server, I am not able to lookup the Session Bean deployed in JBoss App Server.

When I use the above obtained InitialContext, and do a lookup like "Object obj = getJBContext().lookup("invoiceBean");" the returned Object is 'null'. As I mentioned above, this happens after I bounce the JBoss App Server, and wouldn't go away until I bounce the Weblogic App Server as well.

This is the expected behaviour. Your reference to the session bean home is no longer valid - this is a reference to a physical instance. That instance was destroyed as soon as you destroyed the container in which it was manifested.

You'll get the same issue if you redeployed the EJB as the old physical instance is destroyed and the new instance is created.

I understand that, when once the JBoss App Server was bounced, I will no longer have a valid reference to the Session Bean's Home....

But, what I don't understand is, why can't I lookup the Session Bean again, by creating a new InitialContext Object (just as I did at the very beginning -- when both servers have just been started)....

After I catch the NoSuchObjectException, I am creating a brand new InitialContext object, butall I get back in return when I lookup the SessionBean, using this freshly created InitialObject is'null'....why do you think that's happening?

How about killing the JBoss server and trying to get a reference? In theory, you should get a problem connecting to the JNDI service. That would show that you're not going for a second lookup. And we could go from there.

After 4 days of seemingly endless frustration, I was able to resolve this problem...thought that I would share this info with you...and to let you know how stupid I was...

While going thru the EJB Spec, I saw the following 3 lines as regards to an MDB...

************A message-driven bean instance has no state for a specific client. However, the instance variables of themessage-driven bean instance can contain state across the handling of client messages. Examples ofsuch state include an open database connection and an object reference to an EJB object.*************

And in my MDB, I have declared the remote bean I am trying to lookup, as an instance variable. And also the Context object in my ServiceLocator (which I invoke from my MDB) is declared as an instance variable. So, what's happening is, when once the initialcontext lookup returns a 'null' object (since the remote JBoss app server is bounced), that state isn't getting changed when other MDB instances try to process messages. When I saw the above info in the EJB 2.0 spec, I changed my remote object reference and the context object reference to method variables, instead of instance variables...after I made those changes, how many ever times I bounced the JBoss App Server, I was able to consistently lookup the beans deployed there from the Weblogic Server (the first lookup fails though...since the container was destroyed...but, when I catch the 'NoSuchObjectException' and re-try, it works fine)