I have configured a foreign jndi factory to which a link was according!But I dont know how to use the foreign jndi in my own application! could anybody do me a favor???
views:
93answers:
1
A:
Pretty vague question, so pretty vague answer... Here is how to obtain a Context
:
Context ctx = null;
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL,
"t3://localhost:7001");
try {
ctx = new InitialContext(ht);
// Use the context in your program
}
catch (NamingException e) {
// a failure occurred
} finally {
try {
ctx.close();
} catch (Exception e) {
// a failure occurred
}
}
You'll need wl-client.jar
on the class path. More details in Programming WebLogic JNDI.
PS: I am not swallowing exceptions, the documentation sample does :)
Pascal Thivent
2010-01-26 16:29:02