JBoss 7.1.1 changing JNDI binding in runtime

jboss7.x, jndi, wildfly, wildfly-9

Solution

Should help you: https://docs.jboss.org/author/display/AS71/JNDI+Reference

Topic - Binding entries to JNDI:

An example standalone.xml might look like:

<subsystem xmlns="urn:jboss:domain:naming:1.1" >
  <bindings>
    <simple name="java:global/a" value="100" type="int" />
    <object-factory name="java:global/b" module="com.acme" class="org.acme.MyObjectFactory" />
    <lookup name="java:global/c" lookup="java:global/b" />
 </bindings>
</subsystem>

To add these entries via the CLI:

/subsystem=naming/binding=java\:global\/mybinding:add(binding-type=simple, type=long, value=1000)

To see all all options that are taken by the add command (this can actually be used to get the description of any CLI command):

/subsystem=naming/binding=*:read-operation-description(name=add)

Have not tried, but i hope this helps!

UPDATE - with tested examples:

- Add JDNI name binding `java:global/a`:

/subsystem=naming/binding=java\:global\/a:add(value=10,binding-type=simple,type=java.lang.Integer)

- Read existing JDNI name binding `java:global/a`:

/subsystem=naming/binding=java\:global\/a:read-resource(include-defaults=true)

- Modify JDNI name binding value `java:global/a`:

/subsystem=naming/binding=java\:global\/a:write-attribute(name=value, value=20)

- Remove JDNI name binding `java:global/a`:

/subsystem=naming/binding=java\:global\/a:remove()

Executing command directly from shell:

./jboss-cli.sh --connect --command="/subsystem=naming/binding=java\:global\/a:read-resource(include-defaults=true)"

Problem

In JBoss 7.1.1 in standalone mode all JNDI bindings are configured in standalone.xml file in jboss:domain:naming:1.1 subsystem. According to documentation standalone.xml cannot be modified when server is running. I've tried to use JBoss CLI but I don't know how to write/modify resource. How to change value in JNDI without restarting jboss?

Original source