Bug 856819

Summary: [as7, CLI] NullPointerException when trying to deploy war on EAP 6 in domain mode using CLI and createPackageBackedResource method
Product: [Other] RHQ Project Reporter: Larry O'Leary <loleary>
Component: CLIAssignee: Jay Shaughnessy <jshaughn>
Status: CLOSED CURRENTRELEASE QA Contact: Mike Foley <mfoley>
Severity: high Docs Contact:
Priority: urgent    
Version: 4.4CC: bkramer, hrupp, jshaughn
Target Milestone: ---   
Target Release: RHQ 4.5.0   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 856186 Environment:
Last Closed: 2013-09-01 10:00:07 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 856186    

Description Larry O'Leary 2012-09-12 20:43:25 UTC
+++ This bug was initially created as a clone of product Bug #856186 +++

Description of problem:
I tried to deploy war file on EAP 6 in domain mode using the following:

*******
var deploymentResourceType = ResourceTypeManager.getResourceTypeByNameAndPlugin('DomainDeployment', 'JBossAS7');

var criteria = new ResourceCriteria();
criteria.addFilterResourceKey("/home/JBoss/jboss-eap-6.0/domain");
var domain = ResourceManager.findResourcesByCriteria(criteria).iterator().next();

var domainProxy = ProxyFactory.getResource(domain.getId());

var deployConfig = new Configuration();
deployConfig.put(new PropertySimple("runtimeName", domainProxy.name));

var file = new java.io.File("/home/HelloWorld.war");
var inputStream = new java.io.FileInputStream(file);
var fileLength = file.length();
var fileBytes = java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, fileLength);
for (numRead=0, offset=0; ((numRead >= 0) && (offset < fileBytes.length)); offset += numRead ) {numRead = inputStream.read(fileBytes, offset, fileBytes.length - offset);}
500238

var histo = ResourceFactoryManager.createPackageBackedResource(domain.getId(),deploymentResourceType.id, domainProxy.name, null, "kitchensink", "1.0", null, deployConfig, fileBytes, 500000)
*******
There is no error reported back and I can see the following line in server.log file:

[Host Controller] 11:56:47,996 INFO  [org.jboss.as.repository] (HttpManagementService-threads - 2) JBAS014900: Content added at location /home/JBoss/jboss-eap-6.0/domain/data/content/7a/8d0d406226c5c578bca957af3669d397af7d00/content

but agent.log file contains the following exception:

2012-09-11 11:56:48,162 DEBUG [ResourceFactory.executor-1] (rhq.core.pc.inventory.ResourceContainer$ResourceComponentInvocationHandler)- Call to [org.rhq.modules.plugins.jbossas7.HostControllerComponent.createResource()] with args [[CreateResourceReport: ResourceType=[{JBossAS7}DomainDeployment], ResourceKey=[null]]] failed.
java.util.concurrent.ExecutionException: java.lang.NullPointerException
	at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:232)
	at java.util.concurrent.FutureTask.get(FutureTask.java:91)
	at org.rhq.core.pc.inventory.ResourceContainer$ResourceComponentInvocationHandler.invokeInNewThreadWithLock(ResourceContainer.java:554)
	at org.rhq.core.pc.inventory.ResourceContainer$ResourceComponentInvocationHandler.invoke(ResourceContainer.java:542)
	at $Proxy72.createResource(Unknown Source)
	at org.rhq.core.pc.inventory.CreateResourceRunner.call(CreateResourceRunner.java:114)
	at org.rhq.core.pc.inventory.CreateResourceRunner.run(CreateResourceRunner.java:95)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
	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:619)
Caused by: java.lang.NullPointerException
	at org.rhq.modules.plugins.jbossas7.BaseComponent.deployContent(BaseComponent.java:409)
	at org.rhq.modules.plugins.jbossas7.HostControllerComponent.createResource(HostControllerComponent.java:115)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	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)
	... 5 more

and "child history" will show unsuccessful attempt to create a child with the following:

2012-09-11 11:56:48,163 INFO  [ResourceFactory.executor-1] (rhq.core.pc.inventory.CreateResourceRunner)- Sending create response to server: CreateResourceResponse[RequestId=10121, Status=Failure]

and HelloWorld.war will not be visible.


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

How reproducible:
Every time.

Steps to Reproduce:
1.
2.
3.
  
Actual results:
NPE is thrown and war file is not visible.

Expected results:
No exception is thrown and deployment is properly done.

Additional info:

Comment 1 Jay Shaughnessy 2012-09-14 19:02:31 UTC
master commmit 123a951be3bd28161cdf7ccf3d45e59124d86489

The AS7 deployment code was relying on PackageVersion.filename being set. But this is not a reliable field, it only reflects the filename of the file uploaded to provide the content.  It can't be used because:
 - It is not set unless the file is tryly uploaded (like in the GUI via
   PackageVersionFileUploadServlet)
 - It is not set via the CLI, or potentially other mechanisms, which supply 
   only the binary content
 - It is not necessarily a valid reflection of the content (i.e. not unique, etc)

The packageName is really the only thing we can use here. It is guaranteed,
is unique, and should reflect the content. It is what is used for similar needs in the previous plugins.

Comment 2 Heiko W. Rupp 2013-09-01 10:00:07 UTC
Bulk closing of items that are on_qa and in old RHQ releases, which are out for a long time and where the issue has not been re-opened since.