jboss jndi上下文是空的 [英] jboss jndi context is empty

查看:151
本文介绍了jboss jndi上下文是空的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

部署到jboss 7的ejb-jar有一个jdni绑定java:global / foo!IFoo。
Jboss管理控制台显示此绑定。
默认情况下,jndi端口为1099。
jboss上的客户端获取该绑定的对象,但是在同一台机器上运行的独立客户端却没有。

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 ?

推荐答案

似乎远程JNDI查找支持仅在JBoss AS 7.1.0上实现。决赛( AS7-1338 )。

It seems remote JNDI lookup support was implemented only on JBoss AS 7.1.0.Final (AS7-1338).

执行远程查找的JNDI属性也发生了变化。您是否可以尝试使用这些JNDI属性实例化 InitialContext

The JNDI properties to perform remote lookups has also changed. Could you try to instantiate the InitialContext with these JNDI properties?

properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
properties.put(Context.PROVIDER_URL, "remote://localhost:4447");
properties.put(Context.SECURITY_PRINCIPAL, "user");
properties.put(Context.SECURITY_CREDENTIALS, "password");

对JNDI树的远程访问是安全的,因此您需要提供用户和密码(通过 add-user.sh / add-user.bat script)添加应用程序用户。

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).

我在我自己的本地服务器上执行了此操作,但返回的$ code> InitialContext.list()仍为空,即使下面的查找工作正常。我在 JBoss论坛上发布了一个答案,但到目前为止还没有运气。

I did this on my own local server, but the NamingEnumeration returned by InitialContext.list() is still empty, even though the lookup below works fine. I posted an answer on JBoss forum, but no luck so far.

// This lookup works fine
System.out.println(ctx.lookup("jms/RemoteConnectionFactory").getClass().getName());
// ... but this list doesn't (empty enumeration)
NamingEnumeration<NameClassPair> list = ctx.list("");

这篇关于jboss jndi上下文是空的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆