Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JBoss 7.1.1 changing JNDI binding in runtime

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?

like image 774
ragnor Avatar asked May 30 '12 06:05

ragnor


2 Answers

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!

like image 189
mik Avatar answered Sep 25 '22 21:09

mik


The question has a lot of views so I'll answer to it. Inspired by @mik response I've figured out that to change value of some JNDI key e.g. java:jboss/api/key to newApiKey run JBoss CLI and execute:

connect
/subsystem=naming/binding=java\:jboss\/api\/key/:write-attribute(name=value,value=newApiKey)

The change will be immediately visible on server and also stored (updated) in standalone.xmlso it won't get lost after server restart.

like image 37
ragnor Avatar answered Sep 23 '22 21:09

ragnor