java - Context.createSubcontext 抛出异常 javax.naming.OperationNotSupportedException

标签 java exception rmi jndi

我已经注册了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/

相关文章:

java - session Bean 是如何工作的?

java - 运行 Tomcat 导致无关项目中的 java.rmi.ServerException

java - 事务未启动 Spring + Hibernate + MySQL

java - 为什么在使用 String.valueOf 或 Float.toString 时此循环会变成无限循环?

Java RMI 应用程序不退出

spring-mvc - SpringMVC异常处理: How to display the parameter being passed in the error page?

javascript - 像在 JS 中一样处理 Python 异常

java - 在 Java servlet 中终止请求花费的时间太长

javascript - 如何将 Json 数据更改为所需的 Json

python - python 异常包含的 errnos 是否与 "linux/errno.h"中的 errnos 相同?