ComputeALot
ComputeALot

Reputation: 21

WebSphere: EJB initial context + cluster lookup

I was wondering whether the following simple code will work, given that I have:

  1. WebSphere ND.

  2. two application servers acting as web-servers.

  3. two application servers acting as application-servers (as cluster X)

Can I access an EJB deployed on the X cluster, using the following code: InitialContext initialContext = new InitialContext(); MyBeanHome = initialContext.lookup("/cells/clusters/X/MyBeanHome");

or: Will the initialContext demand actually specifing servers from which to download the routing table? That is, define properties for the initialContext etc.

The reason I am asking is because I was wondering if WebSphere somehow made it possible to take use of the cell concept and to allow to jndiLookup somehow without specifying the servers on which we use jndi.

Upvotes: 1

Views: 3662

Answers (2)

Manglu
Manglu

Reputation: 11344

The names spaces are all interconnected. Once you get hold of a Naming Server (which is what you do when you get the Intial Context) you can traverse the entire tree as long as you use the Compound name. This compound name has the entire topology which allows the naming server to navigate the federated name space to locate the right resources.

In general, do not hardcode the topology in your application. Work with local names space (java:comp/env). Map these local name spaces to the compound names as part of your application deployment. If the topology changes then you don't need to change your code. You can change the bindings and have the changes ready to be used.

Have a look at these links to get a better understanding

http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.express.doc/info/exp/ae/rnam_names.html

http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.express.doc/info/exp/ae/cnam_name_space_partitions.html

HTH

Manglu

Upvotes: 0

Brett Kail
Brett Kail

Reputation: 33946

Creating an InitialContext from within a server will bootstrap against the server in which you're running, and it will be aware of its cell topology, so you don't need to specify properties with corbaloc, etc.

(I believe the syntax is lookup("cell/clusters/X/MyBeanHome") without the leading "/", though I might be mistaken, and naming might allow both.)

Upvotes: 1

Related Questions