How to list all JNDI entries in “java:global” namespace

时光总嘲笑我的痴心妄想 提交于 2019-12-12 10:42:57

问题


Goal is to list all the JNDI entries programmatically. new InitialContext().list("java:global") doesn't work.

EJB 3.1, Wildfly or Glassfish 4


回答1:


I think that the safer way to navigate in JNDI namespace is first to lookup its root and then list its content.

I've tried this way in WildFly 8.1.0 and it worked :

    Context root = (Context) new InitialContext().lookup("java:global");
    NamingEnumeration<NameClassPair> names = root.list("");


来源:https://stackoverflow.com/questions/26463970/how-to-list-all-jndi-entries-in-javaglobal-namespace

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