How to add a JBoss EAP System Property through JBoss ON CLI 3.3?
Environment
- Red Hat JBoss Operations Network (JON) 3.3.x
- JBoss ON CLI
- Red Hat JBoss Enterprise Application Platform (EAP) 6.x - Standalone Mode
Issue
- How to add a JBoss EAP System Property through JBoss ON CLI 3.3?
- How to update System Properties for JBoss EAP in JON?
Resolution
It is possible to update the System Property list from a JBoss EAP instance (Standalone mode) using JBoss ON CLI. The following JON CLI script provides an example:
- Create a script (i.e.
updating_systemProperty.js); -
Add the JON CLI commands to the script (note that you will have to perform some changes):
// Part 1: Retrieve the EAO resources based on a type (JBossAS7 Standalone Server) and list their IDs var criteria = ResourceCriteria(); criteria.addFilterPluginName("JBossAS7"); criteria.addFilterResourceTypeName("JBossAS7 Standalone Server"); var resources = ResourceManager.findResourcesByCriteria(criteria); pretty.print(resources); // Part 2: It gets the first resource from the list and get its configuration var id = resources.get(0).id; var myConfig = ConfigurationManager.getResourceConfiguration(id); pretty.print(myConfig); // Part 3: Set a new System Property (the System Property list is identified by the name "*2" and PropertyMap needs to be named as "*:name"): var pm = new PropertyMap("*:name"); pm.put(new PropertySimple("name","texto")); pretty.print(pm); pm.put(new PropertySimple("value","hello")); pretty.print(pm); var lista = myConfig.getList("*2"); lista.add(pm); pretty.print(lista); // Part 4: Update the configuration in EAP side (Only execute it if you are sure that the configuration is right) ConfigurationManager.updateResourceConfiguration(id, myConfig); -
Run this script using JON CLI and it should create a new Datasource:
./rhq-cli.sh -u USER -p PASSWORD -f /home/user/updating_systemProperty.js
Note: It should be used only as a reference to create your own scripts. It will be needed to perform tests.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
