我已经注册了JNDI。当我调用 Conrext.createSubcontext 时,出现异常:
javax.naming.OperationNotSupportedException
at com.sun.jndi.rmi.registry.RegistryContext.createSubcontext(RegistryContext.java:226)
at com.sun.jndi.toolkit.url.GenericURLContext.createSubcontext(GenericURLContext.java:390)
at javax.naming.InitialContext.createSubcontext(InitialContext.java:464)
实现如下:
Registry reg = LocateRegistry.createRegistry(1099);
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
properties.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
properties.put(Context.PROVIDER_URL, "localhost:1099");
InitialContext initialContextcontext = new InitialContext(properties);
ic.createSubcontext("rmi://localhost/java:jdbc");
请指出我错过的地方。
最佳答案
提供程序不支持子上下文。 RMI 注册表本身不提供:它提供一维命名空间。
您可能使用了错误的 JNP 提供商。
关于java - Context.createSubcontext 抛出异常 javax.naming.OperationNotSupportedException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16564914/