7

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

EJB 3.1, Wildfly or Glassfish 4

anergy
  • 1,374
  • 2
  • 13
  • 29

1 Answers1

7

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("");
Alexis Hassler
  • 752
  • 5
  • 16
  • 1
    It does help for Wildfly 8.1. But unfortunately not for Glassfish 4, where looking up "java:global" throws exception. I guess no portable solution :( – anergy Oct 27 '14 at 13:28