在glassfishv2中,引入appserv-rt.jar,javaee.jar,并使用如下代码就可以访问jndi了
Properties props = new Properties();
props.setProperty("java.naming.factory.initial",
"com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("java.naming.factory.url.pkgs",
"com.sun.enterprise.naming");
props.setProperty("java.naming.factory.state",
"com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
Context ctx = new InitialContext(props);
ctx.lookup(...)但是在glassfishv3中,根本就找不到com.sun.enterprise.naming.SerialInitContextFactory,官网说引入Include $GLASSFISH_HOME/modules/gf-client.jar in the client's classpath即可,但我引入了这个还是不行。请问如何让standalone java client访问jndi呢?
Properties props = new Properties();
props.setProperty("java.naming.factory.initial",
"com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("java.naming.factory.url.pkgs",
"com.sun.enterprise.naming");
props.setProperty("java.naming.factory.state",
"com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
Context ctx = new InitialContext(props);
ctx.lookup(...)但是在glassfishv3中,根本就找不到com.sun.enterprise.naming.SerialInitContextFactory,官网说引入Include $GLASSFISH_HOME/modules/gf-client.jar in the client's classpath即可,但我引入了这个还是不行。请问如何让standalone java client访问jndi呢?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货