Bug 905183

Summary: [as5 plugin] Unable to collect metric from web application context due to WebApplicationContextComponent not initializing 'clustered' property value
Product: [Other] RHQ Project Reporter: Larry O'Leary <loleary>
Component: PluginsAssignee: Larry O'Leary <loleary>
Status: CLOSED CURRENTRELEASE QA Contact: Mike Foley <mfoley>
Severity: high Docs Contact:
Priority: high    
Version: 4.5CC: hrupp
Target Milestone: ---Keywords: Regression
Target Release: RHQ 4.6   
Hardware: All   
OS: All   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 893217 Environment:
Last Closed: 2013-09-03 10:42:39 EDT Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On:    
Bug Blocks: 893217    

Description Larry O'Leary 2013-01-28 14:12:14 EST
+++ This bug was initially created as a clone of JBoss ON Bug #893217 +++

Description of problem:
Web application context metrics are not being collected and result in an NPE. This is a regression from JBoss ON 3.1.0. The metrics that seem to be affected are:

rejectedSessions, sessionMaxAliveTime, sessionCounter, expiredSessions, maxActive, sessionAverageAliveTime, activeSessions

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

How reproducible:

Steps to Reproduce:
1.  Install and start EAP 5.1.2 server using all profile
2.  Start JBoss ON system
3.  Import EAP server into inventory
4.  Navigate to the *Monitoring* page of the //localhost/jxm-console web application context:

        <platform> / JBossAS Servers / EAP <host:port> all / Applications / Web Application (WAR)s / jmx-console.war / Web Application Contexts / //localhost/jmx-console > Monitoring 

5.  Enable the metric *Currently Active Sessions* and set its collection interval to 1 minute

It may take several minutes for the new value to take affect. It may simply be quicker to restart the agent at this point so that you can be certain that the new collection schedule will take affect.
Actual results:
No metrics appear in JBoss ON UI and agent logs the following error each time metric collection is attempted:

ERROR [ResourceContainer.invoker.daemon-5] (org.rhq.plugins.jbossas5.WebApplicationContextComponent)- Failed to collect metric 'activeSessions' for {JBossAS5}Web Application Context Resource with key localhost.
	at org.rhq.plugins.jbossas5.WebApplicationContextComponent.getValues(WebApplicationContextComponent.java:146)
	at sun.reflect.GeneratedMethodAccessor85.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.inventory.ResourceContainer$ComponentInvocationThread.call(ResourceContainer.java:634)
	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)

Expected results:
Metrics should be collected normally and UI should reflect metrics.

Additional info:
This is a direct result of commit http://git.fedorahosted.org/cgit/rhq/rhq.git/commit/?id=88c286048d73a963eb2e2debd1009d8ed0d595b0 from bug 837510 is what breaks this. Prior to this commit, the variable clustered was initialized. However, this commit changed the type to an object without being initialized resulting in <null> being the default value whereas the existing code does not expect this. It appears that the initialization and retrieval of the web application context's clustered property was re-factored resulting in a non-initialized variable being used when attempting to retrieve the mentioned metrics.

--- Additional comment from Larry O'Leary on 2013-01-08 18:20:41 EST ---

Proposed fix based on master is on branch bug/893217 as commit http://git.fedorahosted.org/cgit/rhq/rhq.git/commit/?h=bug/893217&id=540d85287d3811cfea581e474b600f85ee7b4217.
Comment 1 Larry O'Leary 2013-01-28 14:18:56 EST
Committed to master: http://git.fedorahosted.org/cgit/rhq/rhq.git/diff/?id=4403c93e9f56274644f397174582a0540c0195fc

commit 4403c93e9f56274644f397174582a0540c0195fc
Author: Larry O'Leary <loleary@redhat.com>
Date:   Tue Jan 8 16:59:11 2013 -0600

    Bug 905183 - [as5 plugin] Unable to collect metric from web application context due to WebApplicationContextComponent not initializing 'clustered' property value
    Added code to verify that clustered has been initialized and if it has not, an attempt is made to initialize it. Additionally, it will not be used if it is not initialized.
Comment 2 Heiko W. Rupp 2013-09-03 10:42:39 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.