Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to lookup an EJB reference from a specific server within a cluster

Status
Not open for further replies.

kevinmrohr

Programmer
Mar 20, 2006
1
0
0
US
I am trying to do something unconventional in Weblogic. I have a cluster of servers (server names are dev2, dev3, and dev4), and I am attempting to retrieve an EJB home interface reference from the dev2 server. The EJB I am trying to retrieve is only deployed on dev3 and dev4 so the JNDI lookup should fail if I correctly limit the scope of the lookup to dev2. Unfortunately weblogic's clustering functionality shares a global JNDI tree and distributes the global JNDI tree to each local server, so even though I am able to limit the context to only the dev2 server (which I do by creating an Environment variable and setting the providerURL, then calling getInitialContext on the Environment variable to instantiate the context), the JNDI lookup on the EJB is still being found on the dev3 or dev4 servers.
Here is a small portion of the code I am using:

Code:
Context ctx = localEnv.getInitialContext();
String jndiName = "foo/BarServices";
Object o = ctx.lookup( jndiName );


Ultimately the object o acquires the following value:
"ClusterableRemoteRef(-1413501777340246143S:localhost:[7101,7101,7102,7102,7101,7102,-1,0,0]:localhost:kevinsdomain:dev3 [-1413501777340246143S:localhost:[7101,7101,7102,7102,7101,7102,-1,0,0]:localhost:kevinsdomain:dev3/341])/341"

As you can see, it has found the EJB reference on the dev3 server. I am sure there is a way to specify my jndiName so that it contains the server name that I want to find the EJB reference on, but cannot seem to figure out how it is done.

I have tried also to work backwords by retrieving the javax.naming.Name or javax.naming.CompositeName of the object once I have retrieved it, because that would indicate to me how to formulate the name to do the JNDI lookup including the server name, but I cannot figure out how to retrieve the Name value. The javax.naming.Context has a bunch of functions which take Name as input, but the only ones that return it as output are functions that also require it as input, which still doesn't help me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top