Bug 876658 - AS servers can not be discovered when started as a service (no start script)
Summary: AS servers can not be discovered when started as a service (no start script)
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: RHQ Project
Classification: Other
Component: Agent
Version: 4.5
Hardware: All
OS: Linux
unspecified
high
Target Milestone: ---
: RHQ 4.6
Assignee: Thomas Segismont
QA Contact: Mike Foley
URL:
Whiteboard:
Depends On:
Blocks: 876656
TreeView+ depends on / blocked
 
Reported: 2012-11-14 16:47 UTC by Larry O'Leary
Modified: 2013-09-03 14:45 UTC (History)
3 users (show)

Fixed In Version:
Clone Of: 876656
Environment:
Last Closed: 2013-09-03 14:45:11 UTC
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 162643 0 None None None 2012-11-14 16:47:05 UTC

Description Larry O'Leary 2012-11-14 16:47:04 UTC
+++ 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):
4.4.0.JON310GA

How reproducible:
Always

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 0.0.0.0


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 20:30:47 UTC
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 21:42:45 UTC
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 14:45:11 UTC
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.