1.[代码]常用JNDI初始化上下文
//WebSphere
Properties properties= new Properties();
properties.put(javax.naming.Context.PROVIDER_URL,"iiop:///");
properties.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.ejs.ns.jndi.CNInitialContextFactory");
new InitialContext(properties);
//JBoss
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
p.put(Context.PROVIDER_URL, "jnp://localhost:1099");
InitialContext ctx = new InitialContext(p);
//SUN
Properties props = new Properties();
props.setProperty( "java.naming.factory.initial" ,
"com.sun.enterprise.naming.SerialInitContextFactory" );
//com.sun.jndi.cosnami