jboss jndi context is empty

匿名 (未验证) 提交于 2019-12-03 08:33:39

问题:

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 ?

回答1:

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?

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");

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 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 context is empty
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!