Bug 891567 - Create VM from imported template, via REST, fail on Java NullPointerException in RESTEasy
Summary: Create VM from imported template, via REST, fail on Java NullPointerException...
Keywords:
Status: CLOSED DUPLICATE of bug 875881
Alias: None
Product: Red Hat Enterprise Virtualization Manager
Classification: Red Hat
Component: ovirt-engine-restapi
Version: 3.2.0
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
: ---
Assignee: Libor Spevak
QA Contact: Elena
URL:
Whiteboard: virt
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-01-03 10:04 UTC by Ilanit Stein
Modified: 2014-01-13 01:46 UTC (History)
9 users (show)

Fixed In Version: sf3
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-01-25 10:20:09 UTC
oVirt Team: ---
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
REST log (see error at the bottom of the file, for create 'internal-tools' VM) (53.19 KB, application/octet-stream)
2013-01-03 10:07 UTC, Ilanit Stein
no flags Details
engine log (84.26 KB, application/x-gzip)
2013-01-03 10:13 UTC, Ilanit Stein
no flags Details
vdsm log (895.07 KB, application/x-gzip)
2013-01-03 10:16 UTC, Ilanit Stein
no flags Details

Description Ilanit Stein 2013-01-03 10:04:20 UTC
Description of problem:
Create VM from template that was imported from export to local domain,
via REST. Create VM from same template, via UI succeeds.

Version-Release number of selected component (if applicable):
sf2.1

How reproducible:
Allways

Steps to Reproduce:
1. Import template from export domain to local domain.  
2. Try to create a VM from the template, vi REST. 
  

Comments:
1. As there is a null pointer exception, it is not clear what is the problem exactly. We need to fix this, so that it will be clear what is the problem.
2. On engine log, this action, or any relevant error is not seen.
3. Bug mentioned as regression since on si25.1 it worked OK.
4. This bug root cause should be tracked, to verify it is included in automation tests.

Comment 1 Ilanit Stein 2013-01-03 10:07:38 UTC
Created attachment 671949 [details]
REST log (see error at the bottom of the file, for create 'internal-tools' VM)

Comment 3 Ilanit Stein 2013-01-03 10:13:43 UTC
Created attachment 671950 [details]
engine log

At time stamp 2013-01-03 10:48:49,356  successfull VM creation from UI.
Right before that a Create VM via REST is run and failed, but no failure in this log.

Comment 4 Ilanit Stein 2013-01-03 10:16:15 UTC
Created attachment 671951 [details]
vdsm log

Comment 6 Ilanit Stein 2013-01-03 12:25:57 UTC
The exception in in the REST log (attached).

Comment 7 Yaniv Kaul 2013-01-03 12:27:13 UTC
(In reply to comment #6)
> The exception in in the REST log (attached).

Ah, here it is:
2013-01-03 10:45:31,667 - MainThread - vms - DEBUG - Response body for CREATE request is: <html><head><title>JBoss Web/7.0.17..Final-redhat-1 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The server encountered an internal error () that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>org.jboss.resteasy.spi.UnhandledException: java.lang.NullPointerException
	org.jboss.resteasy.core.SynchronousDispatcher.handleApplicationException(SynchronousDispatcher.java:351)
	org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:220)
	org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:196)
	org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:551)
	org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:513)
	org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:125)
	org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
	org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
	org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

Comment 8 Michael Pasternak 2013-01-03 12:41:52 UTC
From Comment 7 looks like you have not passed any body for CREATE request,
so most likely like the bug in your test rather than in api, also NPE is in
resteasy.spi - way before it get to our application.

Comment 9 Ilanit Stein 2013-01-03 16:20:08 UTC
I'll check that.

Comment 10 Ilanit Stein 2013-01-06 08:37:24 UTC
url and body are passed (copied from the REST log):

2013-01-03 10:45:31,307 - MainThread - vms - DEBUG - CREATE request content is --  url:https://10.35.97.120/api/vms body:<vm>
    <name>internal-tools</name>
    <description>internal-tools</description>
    <type>desktop</type>
    <memory>1073741824</memory>
    <cpu>
        <topology cores="1" sockets="1"/>
    </cpu>
    <os type="unassigned">
        <boot dev="hd"/>
    </os>
    <display>
        <type>spice</type>
        <monitors>1</monitors>
    </display>
    <cluster href="/api/clusters/316a430f-1ead-4fa7-a11f-e79f0760e05a" id="316a430f-1ead-4fa7-a11f-e79f0760e05a">
        <name>nfsToolsTest</name>
        <link href="/api/clusters/316a430f-1ead-4fa7-a11f-e79f0760e05a/networks" rel="networks"/>
        <link href="/api/clusters/316a430f-1ead-4fa7-a11f-e79f0760e05a/permissions" rel="permissions"/>
        <link href="/api/clusters/316a430f-1ead-4fa7-a11f-e79f0760e05a/glustervolumes" rel="glustervolumes"/>
        <cpu id="Intel Conroe Family"/>
        <data_center href="/api/datacenters/f90229a1-7925-4385-b828-7740c68eec48" id="f90229a1-7925-4385-b828-7740c68eec48"/>
        <memory_policy>
            <overcommit percent="200"/>
            <transparent_hugepages>
                <enabled>true</enabled>
            </transparent_hugepages>
        </memory_policy>
        <scheduling_policy/>
        <version major="3" minor="1"/>
        <error_handling>
            <on_error>migrate</on_error>
        </error_handling>
        <virt_service>true</virt_service>
        <gluster_service>false</gluster_service>
    </cluster>
    <template id="5b256be8-2c12-4e3d-8357-c8739f9031dd"/>
</vm>
 
2013-01-03 10:45:31,511 - MainThread - core_api - DEBUG - Request response time: 0.020
. . .
2013-01-03 10:45:31,667 - MainThread - vms - DEBUG - Response body for CREATE request is: <html><head><title>JBoss Web/7.0.17..Final-redhat-1 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The server encountered an internal error () that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>org.jboss.resteasy.spi.UnhandledException: java.lang.NullPointerException
	org.jboss.resteasy.core.SynchronousDispatcher.handleApplicationException(SynchronousDispatcher.java:351)
	org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:220)
	org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:196)
	org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:551)
	org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:513)
	org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:125)
	org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
	org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
	org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
</pre></p><p><b>root cause</b> <pre>java.lang.NullPointerException
	org.ovirt.engine.api.restapi.resource.BackendVmsResource.add(BackendVmsResource.java:94)
	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	java.lang.reflect.Method.invoke(Method.java:601)
	org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:167)
	org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:257)
	org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:222)
	org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:211)
	org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:536)
	org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:513)
	org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:125)
	org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
	org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
	org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
</pre></p><p><b>note</b> <u>The full stack trace of the root cause is available in the JBoss Web/7.0.17..Final-redhat-1 logs.</u></p><HR size="1" noshade="noshade"><h3>JBoss Web/7.0.17..Final-redhat-1</h3></body></html> 
2013-01-03 10:45:31,667 - MainThread - vms - ERROR - Response code is not valid, expected is: [200, 201, 202], actual is: 500

Comment 11 Michael Pasternak 2013-01-06 09:46:48 UTC
ok, so Comment 7 did not include entire stack trace, looks like NPE comes from the api: BackendVmsResource.add()

Comment 12 Michal Skrivanek 2013-01-25 10:20:09 UTC
Libor verified already fixed in sf3 now by Arik in the bug 875881

*** This bug has been marked as a duplicate of bug 875881 ***

Comment 13 Libor Spevak 2013-01-25 10:22:37 UTC
Error found for build sf2.1

BackendVmsResource class:

    public Response add(VM vm) {
...
            UsbPolicy usbPolicy = UsbResourceUtils.getUsbPolicy(vm.getUsb(), lookupCluster(staticVm.getvds_group_id())); <---- NPE
...

Already fixed here and merged to 3.2 (duplicate):

restapi: fix usb mapping on update vm call
Bug-Url: https://bugzilla.redhat.com/875881
Signed-off-by: Arik Hadas <ahadas>

    public Response add(VM vm) {
...
            staticVm.setUsbPolicy(VmMapper.getUsbPolicyOnCreate(vm.getUsb(), lookupCluster(staticVm.getVdsGroupId())));
...


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