jboss jndi 上下文为空
部署到 jboss 7 的 ejb-jar 具有 jdni 绑定“java:global/foo!IFoo”。 Jboss 管理控制台显示此绑定。 jndi 端口默认为 1099。 jboss 上的客户端获取该绑定的对象,但在同一台计算机上运行的独立客户端则无法获取该对象。
Properties properties = new Properties();
properties.put("java.naming.factory.initial",
"org.jboss.as.naming.InitialContextFactory");
properties.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
properties.put("java.naming.provider.url","jnp://localhost:1099");
Context ctx = new InitialContext(properties);
NamingEnumeration<NameClassPair> list = ctx.list("");
while (list.hasMore()) {
System.out.println(list.next().getName());
}
没有结果。对上面名称的查找也失败。 问题出在哪里?
An ejb-jar deployed to jboss 7 has a jdni binding "java:global/foo!IFoo".
Jboss management console shows this binding.
The jndi port is 1099 as by default.
A client on jboss gets an object to that binding but a standalone client running on the same machine does not.
Properties properties = new Properties();
properties.put("java.naming.factory.initial",
"org.jboss.as.naming.InitialContextFactory");
properties.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
properties.put("java.naming.provider.url","jnp://localhost:1099");
Context ctx = new InitialContext(properties);
NamingEnumeration<NameClassPair> list = ctx.list("");
while (list.hasMore()) {
System.out.println(list.next().getName());
}
produces no results. Also the lookup to the name above fails.
Where is the problem ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来远程 JNDI 查找支持仅在 JBoss AS 7.1.0.Final 上实现(AS7-1338)。
用于执行远程查找的 JNDI 属性也已更改。您可以尝试使用这些 JNDI 属性实例化
InitialContext
吗?对 JNDI 树的远程访问是安全的,因此您需要提供用户和密码(通过
add-user.sh
/add-user.bat
脚本)。我在自己的本地服务器上执行了此操作,但
InitialContext.list()
返回的NamingEnumeration
仍然为空,即使下面的查找工作正常。我在 JBoss 论坛 上发布了答案,但到目前为止还没有运气。It seems remote JNDI lookup support was implemented only on JBoss AS 7.1.0.Final (AS7-1338).
The JNDI properties to perform remote lookups has also changed. Could you try to instantiate the
InitialContext
with these JNDI properties?The remote access to the JNDI tree is secured, so you need to provide a user and a password (add an Application User via
add-user.sh
/add-user.bat
script).I did this on my own local server, but the
NamingEnumeration
returned byInitialContext.list()
is still empty, even though the lookup below works fine. I posted an answer on JBoss forum, but no luck so far.