Bug 876658 - AS servers can not be discovered when started as a service (no start script)
AS servers can not be discovered when started as a service (no start script)
Product: RHQ Project
Classification: Other
Component: Agent (Show other bugs)
All Linux
unspecified Severity high (vote)
: ---
: RHQ 4.6
Assigned To: Thomas Segismont
Mike Foley
Depends On:
Blocks: 876656
  Show dependency treegraph
Reported: 2012-11-14 11:47 EST by Larry O'Leary
Modified: 2013-09-03 10:45 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 876656
Last Closed: 2013-09-03 10:45:11 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 162643 None None None 2012-11-14 11:47:05 EST

  None (edit)
Description Larry O'Leary 2012-11-14 11:47:04 EST
+++ This bug was initially created as a clone of JBoss ON Bug #876656 +++

Description of problem:
AS server discovery fails with the following exception:

WARN  [InventoryManager.discovery-1] (rhq.core.pc.inventory.InventoryManager)- Failure during discovery for [JBossAS Server] Resources - failed after 20 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:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 0
        at java.lang.String.charAt(String.java:686)
        at org.rhq.core.pluginapi.util.ServerStartScriptDiscoveryUtility.getStartScriptIndex(ServerStartScriptDiscoveryUtility.java:295)
        at org.rhq.core.pluginapi.util.ServerStartScriptDiscoveryUtility.getStartScript(ServerStartScriptDiscoveryUtility.java:86)
        at org.rhq.plugins.jbossas5.ApplicationServerDiscoveryComponent.setStartScriptPluginConfigProps(ApplicationServerDiscoveryComponent.java:420)
        at org.rhq.plugins.jbossas5.ApplicationServerDiscoveryComponent.createResourceDetails(ApplicationServerDiscoveryComponent.java:407)
        at org.rhq.plugins.jbossas5.ApplicationServerDiscoveryComponent.discoverExternalJBossAsProcesses(ApplicationServerDiscoveryComponent.java:340)
        at org.rhq.plugins.jbossas5.ApplicationServerDiscoveryComponent.discoverResources(ApplicationServerDiscoveryComponent.java:170)
        at sun.reflect.GeneratedMethodAccessor34.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.rhq.core.pc.util.DiscoveryComponentProxyFactory$ComponentInvocationThread.call(DiscoveryComponentProxyFactory.java:293)
        ... 5 more

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
Not sure yet but the key is that the parent process of the AS JVM process needs to be something similar to the Linux init service.

Actual results:
Discovery of the AS server fails and the agent log contains a warning with the following exception: java.lang.StringIndexOutOfBoundsException: String index out of range: 0

Expected results:
Discovery of the AS server should be successful and the AS start script should be unset.

Additional info:
This issue is a direct result of the parent process that started the JVM not being the expected run.sh or standalone.sh/domain.sh script. For example, if the user starts the JVM directly from the command-line without using a shell script; or as boot when the init system starts its configured services.

In the case of the failure, the parent process command line is:

init [3]                                   

Whereas, what we expect to see is:

/bin/sh ./run.sh -c production -b

Simply put, ServerStartScriptDiscoveryUtility.getStartScriptIndex should not assume that the second argument (or any argument for that matter) has a length of 1 or more.

-            if (serverParentProcessCommandLine[startScriptIndex].charAt(0) != OPTION_PREFIX) {
+            if (serverParentProcessCommandLine[startScriptIndex] != null
+                && serverParentProcessCommandLine[startScriptIndex].length() > 0
+                && serverParentProcessCommandLine[startScriptIndex].charAt(0) != OPTION_PREFIX) {
Comment 1 Thomas Segismont 2012-11-30 15:30:47 EST
I think there is already a fix on master: edb9cf7

It was made by Jay 5 months ago but there is no BZ context in the commit comment. 

Jay, do you remember why you add to push this fix?
Comment 2 Larry O'Leary 2012-11-30 16:42:45 EST
I didn't find any BZ associated with it either. Not sure it matters though. It is impacting customers and that should be enough. His fix also matches my proposed fix. We just need to get this back-ported to the product release branch for 3.1.2.
Comment 3 Heiko W. Rupp 2013-09-03 10:45:11 EDT
Bulk closing of issues in old RHQ releases that are in production for a while now.

Please open a new issue when running into an issue.

Note You need to log in before you can comment on or make changes to this bug.