用jboss3.0+tomcat4.03发布EJB,InitialContext环境如何设置

cathy 02-11-05

我在创建好EntityBean以后,发布都通过,但是用以下的client调用此EJB时会抛错:
ActionInfoHome home = null;
Context ctx = new InitialContext();
try{
home = (ActionInfoHome)ctx.lookup("ActionInfo") ;
} catch (javax.naming.NamingException nx) {
throw new RuntimeException("Failed to get ActionInfoHome: caught " + nx);
}

javax.naming.NoInitialContextException;(因为找不到默认的java.naming.factory.initial

请问在Jboss3.0+tomcat4环境下InitialContext()的环境该怎么设?

浆糊
2002-11-05 16:25

需要在classpaht中加入jndi.properties。里面有一些工厂类的配置

cathy
2002-11-05 17:42

请问INITIAL_CONTEXT_FACTORY值应该设为什么?
具体在哪个包里?

浆糊
2002-11-05 21:10

建议看看jboss得文档,上面有很过信息

cathy
2002-11-06 10:41

正确的应该是:
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.SECURITY_PRINCIPAL,"admin");
env.put(Context.SECURITY_CREDENTIALS,"admin");
env.put(Context.PROVIDER_URL, "localhost:1099");
}