1 of 1 people found this helpful
Any context that you create using new InitialContext(props) is very much local to the remote client. context has no information about the remote connections. Your selectors will have it (SelectorA/SelectorB). The only information that Initial context will consider is java.naming.factory.url.pkgs property. So as long as your SelectorB knows about serverA, it should work. By calling EJBClientContext.setSelector(SelectorB); you are ultimately replacing all receivers/connection information. So whether ctx.lookup(bean_on_serverA); & context.lookup(bean_on_serverB); would work or not is all depends on whether SelectorB knows about ServerA & ServerB.
Ok thanks! But what if we have servers with the same beans deployed on them? Is it possible to lookup on specifik server even though the selector knows about 2 servers?
Is it possible to lookup on specifik server even though the selector knows about 2 servers?
At the moment using remoting API, I don't think so.
As a workaround you may want to try separating out selectors for two servers & try setting them just before you want to do a lookup:
ctx = new InitialContext(propsA);
SelectorA = EJBClientContext.setSelector(SelectorB); // when you set SelectorB, this call will return previously set selector, if any, which in this case will be SelectorA
// if needed set SelectorA back
SelectorB = EJBClientContext.setSelector(SelectorA);
//do the stuff with SelectorA
I haven't tried this myself, but would be worth to give a try.
Here is another user Bernd Koecke asking same thing https://community.jboss.org/message/647202#647202#647202 Will be worth to see what architects responds.