After detecting/importing an AS 7 instance, JON can execute an operation: "install an RHQ user" which is intended to add a user/password to the mgmt-users.properties file in "domain/configuration" or in "standalone/configuration" AS supports moving the base directory, for example "standalone" and up to a point JON supports that. However, AS also supports moving the "configuration" directory either with a relative path or an absolute path. The JON plugin does not cope with this. The problem is located in rhq/source/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/helper/HostConfiguration.java "relative-to" is a so called "named path"; an alias for a directory. "path" is either relative to the resolved "relative-to" setting, or when the latter is not set, an absolute path example: path: mgmt-users.properties relative-to: jboss.server.config.dir Full path: /opt/jboss/standalone/configuration/mgmt-users.properties However, if "jboss.server.config.dir" has been redefine, lets say "/var/jboss/config"; then the above resolved to /var/jboss/config/mgmt-users.properties JON code breaks on this: 217 public File getSecurityPropertyFile(File baseDir, AS7Mode mode, String realm) { 218 String fileName = obtainXmlPropertyViaXPath("//security-realms/security-realm[@name='" + realm 219 + "']/authentication/properties/@path"); 220 String relDir = obtainXmlPropertyViaXPath("//security-realms/security-realm[@name='" + realm 221 + "']/authentication/properties/@relative-to"); 222 223 String dmode; 224 if (mode == AS7Mode.STANDALONE) 225 dmode = "server"; 226 else 227 dmode = "domain"; 228 229 File configDir; 230 if (relDir.equals("jboss." + dmode + ".config.dir")) { 231 configDir = new File(baseDir, "configuration"); 232 } else { 233 configDir = new File(relDir); 234 } 235 File securityPropertyFile = new File(configDir, fileName); 236 237 return securityPropertyFile; 238 } problematic lines are: 229 File configDir; 230 if (relDir.equals("jboss." + dmode + ".config.dir")) { 231 configDir = new File(baseDir, "configuration"); 232 } else { 233 configDir = new File(relDir); 234 } 235 File securityPropertyFile = new File(configDir, fileName); 236 237 return securityPropertyFile; 238 } As (for now) I assume the plugin cannot resolve the relative-to named path, a first correction to the code should be: 230 if (relDir == null || relDir.isEmpty()) { 231 return new File(fileName); 232 } else { 233 return new File(baseDir, "configuration"); 234 } 238 } This at least allows customers to set "path" to a fully qualified pathname for the file (and remove relative-to) thus allowing to have the configuration directory elsewhere. A better solution would be: 230 if (relDir == null || relDir.isEmpty()) { 231 return new File(fileName); 232 } else { 233 return new File(resolveNamedPath(relDir)); 234 } 238 } resolveNamedPath(..) would need to be able to ask JBoss to resolve the named path of course. I'm not sure if that is possible right now. I presume "AS7Mode mode" would need to be extended to take the configuration directory
in master commit b43e1a33a9d81410caf030c0deea857b2b767ba7 Author: Libor Zoubek <lzoubek> Date: Thu Jul 10 17:20:21 2014 +0200 Bug 1093374 - JON plugin for AS 7 cannot create an admin user in a moved configuration directory Original HostConfiguration#getSecurityPropertyFile is now deprecated, new implementation takes ServerPluginConfiguration as a parameter instead of baseDir and properly resovles 'relative-to' attribute value (according to AS7 XSD Doc this value can be a any AS7 path name). ServerPluginConfiguration has now method called getPath(String) which accepts path-name and if known by plugin, appropriate File instance is returned.