Bug 839087

Summary: JMX Plugin - Unsupported key type: Legacy
Product: [Other] RHQ Project Reporter: Elias Ross <genman>
Component: PluginsAssignee: Simeon Pinder <spinder>
Status: CLOSED CURRENTRELEASE QA Contact: Mike Foley <mfoley>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 4.5CC: hrupp, spinder
Target Milestone: ---   
Target Release: RHQ 4.5.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 856374 (view as bug list) Environment:
Last Closed: 2013-09-01 10:03:54 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 856374    

Description Elias Ross 2012-07-10 21:57:08 UTC
Description of problem:

If the process command line does not include the main class name (i.e. it was truncated) then the following may occur with the JMX plugin:

2012-07-10 21:39:22,315 DEBUG [ResourceDiscoveryComponent.invoker.daemon-1] (org.rhq.plugins.jmx.JMXDiscoveryComponent)- JMX service URL for java process [pro
cess: pid=[22589], name=[/usr/java/default/bin/java], ppid=[1]] is [service:jmx:rmi:///jndi/rmi://127.0.0.1:8013/jmxrmi].
2012-07-10 21:39:22,316 DEBUG [ResourceDiscoveryComponent.invoker.daemon-1] (org.rhq.plugins.jmx.JMXDiscoveryComponent)- Using JMX remoting port [8013] as Resource key...
2012-07-10 21:39:22,316 DEBUG [ResourceDiscoveryComponent.invoker.daemon-1] (org.rhq.plugins.jmx.JMXDiscoveryComponent)- Error when trying to discover JVM pro
cess [ProcessScanResult: scan=[ProcessScan: query=[process|basename|match=^java.*,arg|-cp|match=.*/.../.*], name=[...]], info=[process: pid=[22589],
 name=[/usr/java/default/bin/java], ppid=[1]]].
java.lang.IllegalStateException: Unsupported key type: Legacy
        at org.rhq.plugins.jmx.JMXDiscoveryComponent.buildResourceName(JMXDiscoveryComponent.java:520)
        at org.rhq.plugins.jmx.JMXDiscoveryComponent.buildResourceDetails(JMXDiscoveryComponent.java:424)
        at org.rhq.plugins.jmx.JMXDiscoveryComponent.discoverResourceDetails(JMXDiscoveryComponent.java:415)
        at org.rhq.plugins.jmx.JMXDiscoveryComponent.discoverResources(JMXDiscoveryComponent.java:132)



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

5.4

How reproducible:

Always

Steps to Reproduce:
1. Create a command line that does not include a main class but includes a JMX port
2. Attempt to 'discover' this resource


Fix:

diff --git a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXDiscoveryComponent.java b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXDisco
index f0a4f98..1937092 100644
--- a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXDiscoveryComponent.java
+++ b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXDiscoveryComponent.java
@@ -512,6 +512,9 @@ public class JMXDiscoveryComponent implements ResourceDiscoveryComponent, Manual
         }
 
         switch (key.getType()) {
+            case Legacy:
+                // implies main classname was not found
+                name.append(key.getJmxRemotingPort()); break;
             case JmxRemotingPort:
                 name.append(':').append(key.getJmxRemotingPort()); break;
             case Explicit:

... I haven't tested this yet though

Comment 1 Simeon Pinder 2012-09-11 22:22:10 UTC
Hi Elias,

  This diff does solve the issue and I applied the diff with you as the committer.

This is fixed in master with commits:
ad3c40c0812d747
c431e51a08fbb69
1d4e0d12dc0d013

Comment 2 Simeon Pinder 2012-09-11 22:27:18 UTC
Moving this to ON_QA.

Comment 3 Heiko W. Rupp 2013-09-01 10:03:54 UTC
Bulk closing of items that are on_qa and in old RHQ releases, which are out for a long time and where the issue has not been re-opened since.