Bug 996582 - [JBossAS7] - creating datasource via CLI fails because of NPE
[JBossAS7] - creating datasource via CLI fails because of NPE
Product: RHQ Project
Classification: Other
Component: CLI, Plugins (Show other bugs)
Unspecified Unspecified
unspecified Severity high (vote)
: ---
: RHQ 4.9
Assigned To: Thomas Segismont
Mike Foley
Depends On:
  Show dependency treegraph
Reported: 2013-08-13 09:23 EDT by Filip Brychta
Modified: 2013-09-24 15:09 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2013-09-24 15:09:40 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
script with repro steps (1.63 KB, application/javascript)
2013-08-13 09:23 EDT, Filip Brychta
no flags Details

  None (edit)
Description Filip Brychta 2013-08-13 09:23:54 EDT
Created attachment 786160 [details]
script with repro steps

Description of problem:
Creating 'DataSource (Standalone)' resource via CLI fails with NPE. All required parameters (connection-url,jndi-name,driver-name) are set. NPE is thrown when 'enabled' parameter is unset. See attached script for detailed info. 

Version-Release number of selected component (if applicable):
Version: 4.9.0-SNAPSHOT
Build Number: c9283bd

How reproducible:

Steps to Reproduce:
1. JBossAS7 Standalone Server is imported
2. run attached test.js script (./rhq-cli.sh -s <serverIP> -p rhqadmin -u rhqadmin -f test.js)

Actual results:
Child creation fails with following exception (visible on GUI - eap->datasources->Inventory->Child History):
	at org.rhq.modules.plugins.jbossas7.DatasourceComponent.createResource(DatasourceComponent.java:139)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:616)
	at org.rhq.core.pc.inventory.ResourceContainer$ComponentInvocation.call(ResourceContainer.java:654)
	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:679)
Comment 1 Thomas Segismont 2013-08-21 08:41:45 EDT
This is because enabled is a required attribute and the resource configuration you have built does not have it.

I'm looking for a way to retrieve a default resource configuration from the server.
Comment 2 Thomas Segismont 2013-08-21 12:44:55 EDT
(In reply to Thomas Segismont from comment #1)
> This is because enabled is a required attribute and the resource
> configuration you have built does not have it.

Sorry I understood the problem in reverse order. So, you're right, 'enabled' attribute is not a required attribute and does not need to be sent. Fixed that in master.

commit b1c756593a32f47ae2bafaa0466fecddd5bf721d
Author: Thomas Segismont <tsegismo@redhat.com>
Date:   Wed Aug 21 18:42:35 2013 +0200

By the way, maybe you already know, but if you need to create a config object with default values for required attributes you can do this:

var confDef = ConfigurationManager.getResourceConfigurationDefinitionForResourceType(resType.id)

var conf = org.rhq.core.domain.configuration.ConfigurationUtility.createDefaultConfiguration(confDef);
Comment 3 Filip Brychta 2013-08-22 04:24:17 EDT
Verified on
Version: 4.9.0-SNAPSHOT
Build Number: 434b099
Comment 4 Heiko W. Rupp 2013-09-24 15:09:40 EDT
Bulk closing of RHQ 4.9 verified items

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