Failed to create instance for Resource ? ? ? How to solve it...
arun2arunraj Jul 23, 2013 8:27 AMHi Developers,
I am creating custom plugin. For that I am discovering 5 child resources. Resources are being discovered by container. I have updated my plugin (haven't changed anything in discoveryComponent) , I got the following error without capturing any exception or stackTrace.
2013-07-22 19:26:29,021 ERROR [ResourceDiscoveryComponent.invoker.daemon-3] (org.rhq.plugins.customQA.EmailDiscoveryComponent)- 2013-07-22 19:26:29,021 ERROR [ResourceDiscoveryComponent.invoker.daemon-3] (org.rhq.plugins.customQA.UserDiscoveryComponent)- 2013-07-22 19:26:29,021 ERROR [ResourceDiscoveryComponent.invoker.daemon-2] (org.rhq.plugins.customQA.WebServiceDiscoveryComponent)-
Appart from this log(Agent Log) , I dont find anything.
Due to this error, Not sure. I cant collect values for my child resources.
Out of five child resources, Only One child resource is collecting values. All other resources are not collecting values. Please help me to find this problem.
Sample of my code is following :
Class EmailComponent implements ResourceComponent<ParentClass> , MeasurementFacet { private ResourceComponent<ParentClass> Email; private ArrayList<Integer> mEmailCount = new ArrayList<Integer>(); public void start(ResourceContext<ParentClass> context) throws InvalidPluginConfigurationException, Exception{ Email = context; } public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> request) throws Exception { mEmailCount.addAll(Email.getParentResourceComponent().getPARENT_CLASS_METHOD_NAME()); // Collecting arrayList values from parentResource. for(MeasurementScheduleRequest metric : request ) { if(metric.getName.equals("EmailCount")) { report.addData( new MeasurementDataNumeric( metric, new Double(mEmailCount(index).doubleValue()))); //index will be dependent on each customer based on some good logic. /* Logic is not a issue. It will work fine. */ } } } }
Above is my sample code which I have written to collect the values.
In the above code, Out of my five child resource, One child resource is collecting value. Other resources are putting error message like the following
2013-07-23 17:51:32,809 WARN [MeasurementManager.collector-1] (rhq.core.pc.measurement.MeasurementCollectorRunner)- Failure to collect measurement data for Resource[id=30232, uuid=5a81cb69-4839-4f65-81e5-c1b4639d867d, type={Monitoring System-RHQ Plugin-Final-05}User Service, key=keyword, name=monitor, parent=Monitoring System] - cause: java.lang.IndexOutOfBoundsException: Size: 0
Then Only I came to know, values are not being collected for all other child resources. Could anyone please tell me why I got this problem. I think, Object is not instantiated due to the error which i have mentioned before. please guide me to solve this problem.
Regards,
ArunRaj