How to see JNDIView in JBoss EAP6
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 6x
Issue
-
How can I see JNDI tree in EAP 6?
-
Is there something like the EAP 5 JNDIView MBean?
-
I don't know the datasource in the code upfront. I want to access all configured datasources in a generic way, independently if there's only one or ten of them. For each configured datasource I want to get the configuration as it is possible with the cli ?
Resolution
-
Using JBoss CLI utility we can display the JNDI view as following:
-
For Standalone Mode
/subsystem=naming:jndi-view
OUTPUT
/subsystem=naming:jndi-view
{
"outcome" => "success",
"result" => {
"java: contexts" => {
"java:" => {"TransactionManager" => {
"class-name" => "com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate",
"value" => "com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate@169be7b"
}},
"java:jboss" => {
"TransactionManager" => {
"class-name" => "com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate",
"value" => "com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate@169be7b"
},
"TransactionSynchronizationRegistry" => {
"class-name" => "com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple",
"value" => "com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple@30ef2d2f"
},
"UserTransaction" => {
"class-name" => "org.jboss.tm.usertx.client.ServerVMClientUserTransaction",
"value" => "org.jboss.tm.usertx.client.ServerVMClientUserTransaction@3d6d950"
},
"jaas" => {
"class-name" => "$Proxy9",
"children" => {
"jboss-ejb-policy" => {
"class-name" => "org.jboss.as.security.plugins.SecurityDomainContext",
"value" => "org.jboss.security.authentication.JBossCachedAuthenticationManager@6bf1eca"
},
"other" => {
"class-name" => "org.jboss.as.security.plugins.SecurityDomainContext",
"value" => "org.jboss.security.authentication.JBossCachedAuthenticationManager@6d7e633b"
},
"jboss-web-policy" => {
"class-name" => "org.jboss.as.security.plugins.SecurityDomainContext",
"value" => "org.jboss.security.authentication.JBossCachedAuthenticationManager@4a4eea6"
}
}
},
"mail" => {
"class-name" => "javax.naming.Context",
"children" => {"Default" => {
"class-name" => "javax.mail.Session",
"value" => "javax.mail.Session@57c5edee"
}}
},
"datasources" => {
"class-name" => "javax.naming.Context",
"children" => {"ExampleDS" => {
"class-name" => "org.jboss.jca.adapters.jdbc.WrapperDataSource",
"value" => "org.jboss.jca.adapters.jdbc.WrapperDataSource@72c597bd"
}}
}
},
"java:global" => undefined
},
"applications" => {"mysql-connector-java-5.1.13-bin.jar" => {
"java:app" => {
"AppName" => {
"class-name" => "java.lang.String",
"value" => "mysql-connector-java-5.1.13-bin"
},
"env" => {
"class-name" => "org.jboss.as.naming.NamingContext",
"children" => undefined
}
},
"modules" => undefined
}}
}
}
For Domain Mode
As running servers in domain mode. So for this user would need to navigate to the relevant host and runtime server instance.
/host=master/server=server-one/subsystem=naming:jndi-view
by executing above CLI command user will get jndi tree of a server named as server-one on host "master
Additional Note:
-
If we start JBoss EAP6 Standalone profile then using
"$JBOSS_HOME/bin/jconsole.sh"we can open the JConsole in order to navigate the JBoss MBeans. as mentioned in the following link : "How to connect to JBoss EAP6 using JConsole" -
There is an MBean available as
jboss.as:subsystem=namingwhich has an operation namedjndiViewbut invoking this operation does not log the JNDI view in none of the JBoss Log. -
To get JNDI view through DMR API, refer How to see JNDIView using Java based DMR APIs in EAP 6 ? .
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.