Bug 996582 - [JBossAS7] - creating datasource via CLI fails because of NPE
Summary: [JBossAS7] - creating datasource via CLI fails because of NPE
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: RHQ Project
Classification: Other
Component: CLI, Plugins
Version: 4.8
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
: RHQ 4.9
Assignee: Thomas Segismont
QA Contact: Mike Foley
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-08-13 13:23 UTC by Filip Brychta
Modified: 2013-09-24 19:09 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2013-09-24 19:09:40 UTC
Embargoed:


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

Description Filip Brychta 2013-08-13 13:23:54 UTC
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:
Always

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):
java.lang.NullPointerException
	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 12:41:45 UTC
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 16:44:55 UTC
(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>
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 08:24:17 UTC
Verified on
Version: 4.9.0-SNAPSHOT
Build Number: 434b099

Comment 4 Heiko W. Rupp 2013-09-24 19:09:40 UTC
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.