III- Different ways to get context
try {
weblogic.jndi.Environment environment = new weblogic.jndi.Environment();
environment.setInitialContextFactory("weblogic.jndi.WLInitialContextFactory");
environment.setProviderUrl("t3://localhost:7101");
environment.setSecurityPrincipal("weblogic");
environment.setSecurityCredentials("weblogic");
environment.setRMIClientTimeout(7000L);
environment.setRequestTimeout(7000L);
ctx1 = environment.getInitialContext();
System.out.println("Got Context1: " + ctx1);
}
catch ( NamingException ne ) {
ne.printStackTrace();
}
This prints WLContext () at the System.out.
OR:
try {
Properties env = new Properties();
env.put("java.naming.factory.initial","weblogic.jndi.WLInitialContextFactory");
env.put("java.naming.factory.host", "127.0.0.1");
env.put("java.naming.factory.port", "7101"); env.put("java.naming.factory.url.pkgs","weblogic.jndi.factories:weblogic.corba.j2ee.naming.url:weblogic.corba.client.naming");
env.put("java.naming.security.principal", "weblogic");
env.put("java.naming.security.credentials", "weblogic");
ctx = new InitialContext(env);
System.out.println("Got Context: " + ctx);
}
catch ( NamingException ne ) {
ne.printStackTrace();
}
OR without security: Hashtable env = new Hashtable(5);
env.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL,"t3://weblogicServer:7101");
Context ctx = new InitialContext(env);
IMPORTANT NOTE: The PORT number may be 7001 instead of 7101 depending on the installation.
( prev ) ( next )