modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java | 50 ++++++---- 1 file changed, 30 insertions(+), 20 deletions(-)
New commits: commit 8130e34b50dfc81ae0074ac789d784d159b7b9aa Author: John Mazzitelli mazz@redhat.com Date: Fri May 10 17:01:01 2013 -0400
BZ 699893 911692 - if the user ran EAP 5 with cmd line option -Djboss.server.data.dir=/some/data/dir then the AS5 plugin should look there, too, to try to find the jnp-service.url file
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java index 01eb105..670347f 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java @@ -500,32 +500,42 @@ public class ApplicationServerDiscoveryComponent implements ResourceDiscoveryCom }
private String getJnpURL(JBossInstanceInfo cmdLine, File installHome, File configDir) { - File jnpServiceUrlFile = new File(configDir, "data/jnp-service.url"); - if (jnpServiceUrlFile.exists() && jnpServiceUrlFile.canRead()) { - BufferedReader br = null; - try { - br = new BufferedReader(new FileReader(jnpServiceUrlFile)); - String jnpUrl = br.readLine(); - if (jnpUrl != null) { - if (log.isDebugEnabled()) { - log.debug("Read JNP URL from jnp-service.url file: " + jnpUrl); + ArrayList<File> possibleJnpServiceUrlFiles = new ArrayList<File>(2); + possibleJnpServiceUrlFiles.add(new File(configDir, "data/jnp-service.url")); + // if the app server was told to go somewhere else to store its data files, look in there too (BZ 699893) + if (cmdLine.getSystemProperties() != null) { + String dataDir = cmdLine.getSystemProperties().getProperty("jboss.server.data.dir"); + if (dataDir != null) { + possibleJnpServiceUrlFiles.add(new File(dataDir, "jnp-service.url")); + } + } + for (File jnpServiceUrlFile : possibleJnpServiceUrlFiles) { + if (jnpServiceUrlFile.exists() && jnpServiceUrlFile.canRead()) { + BufferedReader br = null; + try { + br = new BufferedReader(new FileReader(jnpServiceUrlFile)); + String jnpUrl = br.readLine(); + if (jnpUrl != null) { + if (log.isDebugEnabled()) { + log.debug("Read JNP URL from jnp-service.url file: " + jnpUrl); + } + return jnpUrl; } - return jnpUrl; - } - } catch (IOException ioe) { - // Nothing to do - } finally { - if (br != null) { - try { - br.close(); - } catch (IOException e) { - // nada + } catch (IOException ioe) { + // Nothing to do + } finally { + if (br != null) { + try { + br.close(); + } catch (IOException e) { + // nada + } } } } }
- log.warn("Failed to read JNP URL from '" + jnpServiceUrlFile + "'."); + log.warn("Failed to read JNP URL from: " + possibleJnpServiceUrlFiles);
// Above did not work, so fall back to our previous scheme JnpConfig jnpConfig = getJnpConfig(installHome, configDir, cmdLine.getSystemProperties());
rhq-commits@lists.fedorahosted.org