Description of problem: When -P/--properties command-line option is passed to domain.sh, jboss-as-7 plug-in fails to execute discovery due to: ERROR [ResourceDiscoveryComponent.invoker.daemon-1] (rhq.modules.plugins.jbossas7.HostControllerDiscovery)- Discovery of a JBossAS7 Host Controller Resource failed for process: pid=[8729], name=[/etc/alternatives/java_sdk/bin/java], ppid=[8712]. java.lang.NullPointerException at org.rhq.modules.plugins.jbossas7.AS7CommandLine.getAbsoluteFile(AS7CommandLine.java:185) at org.rhq.modules.plugins.jbossas7.AS7CommandLine.toURL(AS7CommandLine.java:161) at org.rhq.modules.plugins.jbossas7.AS7CommandLine.processClassArgument(AS7CommandLine.java:132) at org.rhq.core.pluginapi.util.JavaCommandLine.parseClassArguments(JavaCommandLine.java:194) at org.rhq.core.pluginapi.util.JavaCommandLine.parseCommandLine(JavaCommandLine.java:159) at org.rhq.core.pluginapi.util.JavaCommandLine.<init>(JavaCommandLine.java:136) at org.rhq.modules.plugins.jbossas7.AS7CommandLine.<init>(AS7CommandLine.java:69) at org.rhq.modules.plugins.jbossas7.AS7CommandLine.<init>(AS7CommandLine.java:74) at org.rhq.modules.plugins.jbossas7.BaseProcessDiscovery.discoverResources(BaseProcessDiscovery.java:135) at sun.reflect.GeneratedMethodAccessor26.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:616) at org.rhq.core.pc.util.DiscoveryComponentProxyFactory$ComponentInvocationThread.call(DiscoveryComponentProxyFactory.java:293) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:636) Version-Release number of selected component (if applicable): 4.4.0.JON312GA How reproducible: Always Steps to Reproduce: 1. Install EAP 6 2. Create empty system.properties file: touch "${JBOSS_HOME}/bin/system.properties" 3. Start EAP domain with -P command-line argument passing the relative path value system.properties: cd "${JBOSS_HOME}/bin" ./domain.sh -P system.properties 4. Start JBoss ON system 5. Wait for server discovery to execute Actual results: AS/EAP domain is not discovered and agent log contains the following error: ERROR [ResourceDiscoveryComponent.invoker.daemon-1] (rhq.modules.plugins.jbossas7.HostControllerDiscovery)- Discovery of a JBossAS7 Host Controller Resource failed for process: pid=[8729], name=[/etc/alternatives/java_sdk/bin/java], ppid=[8712]. java.lang.NullPointerException at org.rhq.modules.plugins.jbossas7.AS7CommandLine.getAbsoluteFile(AS7CommandLine.java:185) Expected results: AS/EAP domain should be discovered. Additional info: This is just the surface of the issue. Specifically, the exception is caused by the attempted use of the this.log which has not yet been initialized seeing that the constructor is still being executed. The next issue is that this.process is referenced yet it also has not been initialized because it doesn't get initialized until later. Finally, as a last resort an attempt is made to read the jboss.home.dir property to make the path to --properties absolute but that system property has not yet been parsed and therefore is not yet defined. So, to fix this, we must first fix the inheritance issue. We should not be invoking private/protected non-static methods from the constructors that require an already initialized instance of the class. This can be seen in the log and process fields of the class. Then, we should probably add logic to handle the situation of jboss.home.dir not yet being defined: String homeDir = getSystemProperties().get(HOME_DIR_SYSPROP); if (homeDir != null) { File binDir = new File(homeDir, "bin"); absoluteFile = new File(binDir, file.getPath()); } else { ... to: String homeDir = getSystemProperties().get(HOME_DIR_SYSPROP); if (homeDir == null) { List<String> args = this.getArguments(); if (args != null) { for (String arg : args) { if ( arg != null && arg.startsWith("-D" + HOME_DIR_SYSPROP + "=")) { ... } } } } if (homeDir != null) { File binDir = new File(homeDir, "bin"); absoluteFile = new File(binDir, file.getPath()); } else {
The code as it is right now both in the generic JavaCommandLine and in the concrete AS7CommandLine will have to be reworked. Calling overriden methods in the super constructor is just a bad idea.
A fix is in the master branch, tracked by BZ 907558.
Assigned this to Lukas has he did the commit upstream. This was committed to master as 2910d155e509b6ebccdc9483a70b2910bdf0133c and will be brought into ON 3.2 when the 3.2 branch is created from master. Moving to MODIFIED as this fix should be in 3.2.0.ER01
Appears the upstream fix introduces a new failure: 2013-02-06 09:36:54,077 WARN [InventoryManager.discovery-1] (rhq.core.pc.inventory.InventoryManager)- Failure during discovery for [JBossAS7 Standalone Server] Resources - failed after 150 ms. java.lang.Exception: Discovery component invocation failed. at org.rhq.core.pc.util.DiscoveryComponentProxyFactory$ComponentInvocationThread.call(DiscoveryComponentProxyFactory.java:297) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:636) Caused by: java.lang.NoSuchMethodError: org.rhq.modules.plugins.jbossas7.AS7CommandLine.isArgumentsParsed()Z at org.rhq.modules.plugins.jbossas7.AS7CommandLine.getAppServerArguments(AS7CommandLine.java:89) at org.rhq.modules.plugins.jbossas7.BaseProcessDiscovery.setStartScriptPluginConfigProps(BaseProcessDiscovery.java:277) at org.rhq.modules.plugins.jbossas7.BaseProcessDiscovery.buildResourceDetails(BaseProcessDiscovery.java:198) at org.rhq.modules.plugins.jbossas7.StandaloneASDiscovery.buildResourceDetails(StandaloneASDiscovery.java:84) at org.rhq.modules.plugins.jbossas7.BaseProcessDiscovery.discoverResources(BaseProcessDiscovery.java:136) at sun.reflect.GeneratedMethodAccessor47.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:616) at org.rhq.core.pc.util.DiscoveryComponentProxyFactory$ComponentInvocationThread.call(DiscoveryComponentProxyFactory.java:293) ... 5 more Setting to ON_DEV and will update the upstream bug(s).
Based on https://bugzilla.redhat.com/show_bug.cgi?id=907558#c3 from upstream bug, this error was actually caused by testing the patch. The patch has no dependencies on other components and therefore when testing the patch, the agent side changes that were made for this fix were not available. However, this fix as it stands for 3.2 is fine. Moving back to MODIFIED.
Verified on Version: 3.2.0.ER4 Build Number: e413566:057b211 Installed EAP6.1.0 and started EAP domain with -P command-line argument passing the relative path value of the empty system.properties file. The EAP Domain Controller is discovered successfully without error in agent log.