As of JBOSS 7.1 you can easily create and access objects in JNDI. This is helpful, if the administration needs to set some parameter for a application. I don’t want anyone to mess with my ear- or warfiles.

Search in the standalone.xml (or which configuration file is in use) for the following element:

<subsystem xmlns="urn:jboss:domain:naming:1.2">

Write your configuration entries:

<subsystem xmlns="urn:jboss:domain:naming:1.2">
           <simple name="java:global/myEntry" value="4" type="int"/>
           <simple name="java:global/myStringEntry" value="YEAH"/>

Search for the schema file jboss-as-naming_1_2.xsd if your wondering, what can be used here.

To acces the information use a little EE6 magic:

import javax.annotation.Resource;
@Resource(lookup = "java:global/myStringEntry")
private String testString;
@Resource(lookup = "java:global/myEntry")
private int testInt;

That’s it. Here’s the full documentation: