Bug 1382043

Summary: Discovery of ActiveMq fails with NullPointerException when credentials name is not set
Product: [Other] RHQ Project Reporter: bkramer <bkramer>
Component: Core ServerAssignee: Nobody <nobody>
Status: NEW --- QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 4.12CC: hrupp
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 1382041    

Description bkramer 2016-10-05 14:58:17 UTC
Description of problem:
If credname returned by sigar is not set (null) discovery of the ActiveMQ server fails with NullPointerException:

********************************************
DEBUG [ResourceDiscoveryComponent.invoker.daemon-1] (org.jbosson.plugins.fuse.JBossFuseContainerDiscoveryComponent)- Error when trying to discover Fuse Server process [ProcessScanResult: scan=[ProcessScan: query=[process|basename|match=^java.*,arg|-Dkaraf.home|match=.*,arg|-Dkaraf.base|match=.*,arg|*|match=org\.apache\.karaf\.(main|shell\.wrapper)\.Main], name=[null]], info=[process: pid=[29383], name=[/app/software/jdk1.7.0_55/bin/java], ppid=[29336]]].
java.lang.RuntimeException: Failed to extract JMX service URL for process with PID [29383].
	at org.rhq.plugins.jmx.util.JvmUtility.extractJMXServiceURL(JvmUtility.java:93)
	at org.jbosson.plugins.fuse.FuseServerDiscoveryComponent.discoverResourceDetails(FuseServerDiscoveryComponent.java:273)
	at org.jbosson.plugins.fuse.FuseServerDiscoveryComponent.discoverResources(FuseServerDiscoveryComponent.java:94)
	at sun.reflect.GeneratedMethodAccessor43.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.rhq.core.pc.util.DiscoveryComponentProxyFactory$ComponentInvocationThread.call(DiscoveryComponentProxyFactory.java:305)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
	at org.rhq.plugins.jmx.util.JvmUtility.attachToVirtualMachine(JvmUtility.java:107)
	at org.rhq.plugins.jmx.util.JvmUtility.extractJMXServiceURL(JvmUtility.java:76)
	... 10 more
********************************************

Normally, pinfo returns credname set as in [2].

[1] 
*********************************************
[testUser@test lib] java -jar 'sigar-1.6.5.132-6.jar' pinfo 54804
pid=54804
state={Name=java, Threads=332, Tty=0, State=S, Ppid=54760, Processor=1, Priority=20, Nice=0}
mem={Resident=3802157056, PageFaults=37230840, MajorFaults=0, Share=21520384, MinorFaults=37230840, Size=7872376832}
cpu={User=13370920, LastTime=1475081008046, Percent=0.0, StartTime=1474974387000, Total=14365690, Sys=994770}
cred={Euid=25958, Gid=25958, Egid=25958, Uid=25958}
*********************************************

[2] 
*********************************************
[testUser@test lib]$ java -jar 'sigar-1.6.5.132-6.jar' pinfo 26418
pid=26418
state={Name=java, Threads=108, Tty=34819, State=S, Ppid=26368, Processor=7, Priority=20, Nice=0}
mem={Resident=372408320, PageFaults=187036, MajorFaults=0, Share=23486464, MinorFaults=187036, Size=5299863552}
cpu={User=108750, LastTime=1475220798994, Percent=0.0, StartTime=1475159585000, Total=150960, Sys=42210}
cred={Euid=1000, Gid=1000, Egid=1000, Uid=1000}
credname={User=testUser, Group=testUser}
*********************************************

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

How reproducible:
Sometimes (when user is ldap user);

Steps to Reproduce:
1.
2.
3.

Actual results:
Autodiscovery fails and NullPointerException is logged. 

Expected results:
Autodiscovery works and no error is shown in the log file. In case that credname is null, we should try to use some other way of attaching to JVM.

Additional info: