Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to list all JNDI entries in "java:global" namespace

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

EJB 3.1, Wildfly or Glassfish 4

like image 744
anergy Avatar asked Oct 20 '14 10:10

anergy


1 Answers

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("");
like image 107
Alexis Hassler Avatar answered Oct 06 '22 00:10

Alexis Hassler