Bug 837510 - NPE in AS5 plugin
Summary: NPE in AS5 plugin
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: RHQ Project
Classification: Other
Component: Plugins
Version: 4.4
Hardware: Unspecified
OS: Unspecified
medium
unspecified
Target Milestone: ---
: JON 3.1.1
Assignee: Stefan Negrea
QA Contact: Mike Foley
URL:
Whiteboard:
Depends On:
Blocks: 846846
TreeView+ depends on / blocked
 
Reported: 2012-07-04 07:15 UTC by Heiko W. Rupp
Modified: 2013-09-03 15:02 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 846846 (view as bug list)
Environment:
Last Closed: 2013-09-03 15:02:17 UTC
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 893217 0 urgent CLOSED [as5 plugin] Unable to collect metric from web application context due to WebApplicationContextComponent not initializin... 2021-02-22 00:41:40 UTC
Red Hat Knowledge Base (Solution) 290443 0 None None None Never

Internal Links: 893217

Description Heiko W. Rupp 2012-07-04 07:15:55 UTC
From agent.log

2012-07-04 09:14:09,225 WARN  [ResourceContainer.invoker.daemon-2] 
(org.rhq.plugins.jbossas5.WebApplicationContextComponent)- Failed to determine 
whether the web app context localhost is clustered or not.
java.lang.RuntimeException: Failed to load [ComponentType{type=MBean, 
subtype=WebApplicationManager}] ManagedComponent 
[jboss.web:host=localhost,path=/jbossws,type=Manager].
	at 
org.rhq.plugins.jbossas5.ManagedComponentComponent.getManagedComponent(ManagedComponentComponent.java:462)
	at 
org.rhq.plugins.jbossas5.WebApplicationContextComponent.start(WebApplicationContextComponent.java:102)
	at sun.reflect.GeneratedMethodAccessor32.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.inventory.ResourceContainer$ComponentInvocationThread.call(ResourceContainer.java:634)
	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:680)
Caused by: java.lang.NullPointerException
	at 
org.rhq.plugins.jbossas5.ManagedComponentComponent.getManagedComponent(ManagedComponentComponent.java:459)
	... 10 more

Comment 1 Heiko W. Rupp 2012-07-04 07:24:26 UTC
To add: as5 was down at this time, so it is a bit of corner case, but the plugin should nevertheless not throw a NPE.

Comment 2 Stefan Negrea 2012-08-08 20:57:39 UTC
This is clearly an edge case because it happens only if the AS5 server is inventoried but the managing component is not started yet. A possible way to get into this state is to inventory the AS5 server, stop the AS5 server, and then restart the RHQ server. 

I inspected the code very carefully. The errors are just printed to the logs to show something is not right but they do not bubble anywhere. So from that perspective the code is good because it just logs the unusual circumstance and does not prevent the component from getting started.

However, there is one scenario that is not correctly handled by the existing code. If an application is clustered and the scenario presented above happens, when the AS5 server gets online again, the plugin code will not recheck the clustered property, thus leaving the default value for the property (which is not clustered). The clustered flag is used only for a trait and not used by any other external code. Also the value is never refreshed. The operation to check for the clustered flag is very expensive, as it involves calls to the profile service.

To fix this, the code that checks whether an application is clustered or not will be relocated outside of the start method. It will run on the first metrics collection (done only on started components that are available). The getter method that returns the cluster setting will return false until such time. The getter method will be marked as deprecated and left in the code to avoid potential problems with external plugins that rely on the content system. Also, the trait will not be reported by the agent until the property is retrieve successfully from the AS5 server.

Comment 4 John Sanda 2012-08-14 02:16:31 UTC
Moving to ON_QA since JON 3.1.1 ER2 build is availble - https://brewweb.devel.redhat.com/buildinfo?buildID=228250

Comment 5 Armine Hovsepyan 2012-09-06 16:03:32 UTC
verified with the scenario Stefan mentioned.

Comment 6 Heiko W. Rupp 2013-09-03 15:02:17 UTC
Bulk closing of old issues in VERIFIED state.


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