Get the JNDI URL programmatically
https://access.redhat.com/kb/docs/DOC-52143 How to programatically get the JNDI URL in JBoss EAP? Article ID: 52143 - Created on: Mar 9, 2010 2:52 AM - Last Modified: Mar 28, 2011 10:33 AM Issue I need to retrieve the jndi and hajndi urls from within a jboss hosted webservice. Is there some annotation similar to @EJB which might help? Or a property to get? Environment JBoss EAP 4.3 Resolution You can call the mbean server directly to get "jboss:service=Naming" MBean and get the bind address and port. When running in JBoss, the MBean can be acessed as such: ObjectName name = new ObjectName("jboss:service=Naming"); MBeanServer server = (MBeanServer)MBeanServerFactory.findMBeanServer(null).get(0); String bindAddress = (String) server.getAttribute(name, "BindAddress"); Integer port = (Integer) server.getAttribute(name, "Port"); String url = bindAddress + ":" + port; When running outside of JBoss, the MBean can be accessed as such: InitialContext ic = new InitialContext(); RMIAdaptor server = (RMIAdaptor) ic.lookup("jmx/invoker/RMIAdaptor"); ObjectName name = new ObjectName("jboss:service=Naming"); String bindAddress = (String) server.getAttribute(name, "BindAddress"); Integer port = (Integer) server.getAttribute(name, "Port"); String url = bindAddress + ":" + port; Tags: kcs, jboss, eap, jndi, mbean, kcs_verified