9 jms
当我运行JMS相关的应用程序时,我遇到以下异常错误.
javax.naming.NoInitialContextException:需要在环境或系统属性或applet参数或应用程序资源文件中指定类名:java.naming.factory.initial
我们正在使用Sun Application Server 9.1
知道我们缺少什么吗?
我已经尝试添加以下内容但结果仍然相同
Properties env = new Properties();
env.put("java.naming.factory.initial","com.sun.jndi.cosnaming.CNCtxFactory");
Context ctx = new InitialContext(env);
Run Code Online (Sandbox Code Playgroud)
在我的环境中,设置Context.INITIAL_CONTEXT_FACTORY还不够。我还必须设置 Context.URL_PKG_PREFIXES,解释于http://docs.oracle.com/javase/6/docs/api/javax/naming/Context.html#URL_PKG_PREFIXES。