Monday, November 05, 2007

Looking up an EJB home with JNDI

Sometimes it is more convenient for an application to use a corbaname URL as the lookup name. Container-based JNDI clients and thin Java clients can use a corbaname URL. An example of a lookup with a corbaname URL is also included in this section

JNDI lookup from an application running in a container

  java.lang.Object ejbHome =
initialContext.lookup(
"java:comp/env/com/mycompany/accounting/AccountEJB");

JNDI lookup from an application that does not run in a container

java.lang.Object ejbHome = initialContext.lookup(
"cell/nodes/Node1/servers/MyServer/com/mycompany/accounting/AccountEJB");

Server cluster
java.lang.Object ejbHome = initialContext.lookup(
"cell/clusters/MyCluster/com/mycompany/accounting/AccountEJB");

Fixed qualified names
java.lang.Object ejbHome = initialContext.lookup(
"cell/persistent/com/mycompany/accounting/AccountEJB");

JNDI lookup with a corbaname URL
java.lang.Object ejbHome = initialContext.lookup(
"corbaname:iiop:someHost:2809#com/mycompany/accounting/AccountEJB");


ref



No comments: