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?
I was looking exactly for how to add or modify a JNDI binding at runtime, but I needed to to do this in a Wildfly 9 domain (cluster) configuration (not standalone), which is pretty much the same configuration as JBoss 7. However, I couldn't figure out a way to effectively apply changes without restarting all servers.
To start with, enter the JBoss command line interface and connect to your server domain controller:
First, you need to find which profile is active on the server group, so as, on the server root /, enter the following commands:
Afterwards, you should enter the only server group shown in the listing command (ls) by typing
cd {{your_server_group_name}}
, then typels
again and look for an entry named profile to check which one is active. Let's consider full-ha as an active profile for our example.Next, go back to the root configuration folder / by typing
cd ..
and enter the following commands to navigate and view all JNDI bindings available with their current values:By doing this, you'll be able to see all available JNDI bindings and their attributes, if you want to list only binding names, type
ls
instead of the last command.In order to modify a binding, type
cd
and the name of the binding listed in the previous command. Let's suppose you want to change the value of a binding named java:/webservice.url, then you should enterNotice that is necessary to quote some characters in your binding name such as : (colon) and / (slash) with a backslash (\).
To modify an attribute within this binding you should use the :write-attribute command. In this example, let's suppose you want to modify (or add) an attribute named "value" with its content as "this is a value":
So as to apply this change, you'll need to restart all servers in the cluster by typing the following command:
If you want to know more commands to add or remove JNDI bindings check this jboss-cli snippets page
This configuration has been tested successfully in Wildfly 9.0.1