InitialContext parameters for different servers (just a reminder)

I often switch in between WebLogic and GlassFish on my machine. This post is just a reminder to myself – what are parameters for the InitialContext creation in both cases: So WebLogic:

        Hashtable env = new Hashtable(5);
        env.put(Context.INITIAL_CONTEXT_FACTORY,
           "weblogic.jndi.WLInitialContextFactory");
        env.put(Context.PROVIDER_URL,
           "t3://localhost:7001");
        Context ctx = new InitialContext(env);  

And don’t miss the library JAR – it should be wlthint3client.jar

In turn, GlassFish “template” is

Properties props = new Properties();
props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty(Context.URL_PKG_PREFIXES, "com.sun.enterprise.naming");
props.setProperty(Context.STATE_FACTORIES, "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
props.put(Context.PROVIDER_URL, "http://localhost:3700");
Context ct = new InitialContext(props);

JAR file for EJB client should be gf-client.jar

About dnikiforov

I'm writing here about everything what is in my interest - mathematics, physics, Java, Oracle, C++ and other things. These are just remarks about things I'm working with, and if this helps you, guys, in your work - this makes me happy. ;)
This entry was posted in Java. Bookmark the permalink.

Leave a comment