| Summary: | Internal server for request GET /api/hosts in JSON format | ||
|---|---|---|---|
| Product: | [Retired] oVirt | Reporter: | Adam Litke <alitke> |
| Component: | ovirt-engine-api | Assignee: | Ori Liel <oliel> |
| Status: | CLOSED CURRENTRELEASE | QA Contact: | |
| Severity: | unspecified | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | unspecified | CC: | acathrow, dyasny, iheim, juan.hernandez, ykaul |
| Target Milestone: | --- | ||
| Target Release: | 3.1 | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2012-08-09 07:59:07 UTC | Type: | --- |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
The reason for this is that the StorageManager type in the RESTAPI XSD doesn't have a default value for the priority attribute. The code generated by the JAXB compiler looks like this:
protected Integer priority = null;
public int getPriority() {
return priority;
}
The Jackson JSON serializer creates instances of this objects to get default values and the implicit unboxing of the priority attribute generates the NPE. Adding the default value the generated code is this:
protected Integer priority = null;
public int getPriority() {
if (priority == null) {
return 0;
} else {
return priority;
}
}
Proposed patch to fix the issue is available here:
http://gerrit.ovirt.org/3476
The change has been merged. closing ON_QA bugs as oVirt 3.1 was released: http://www.ovirt.org/get-ovirt/ |
Description of problem: Attempting to retrieve the hosts collection in JSON format causes an internal server error: 2012-03-30 16:55:55,882 ERROR [org.jboss.resteasy.core.SynchronousDispatcher] (http--0.0.0.0-8080-4) Failed executing GET /hosts: org.jboss.resteasy.spi.WriterException: org.codehaus.jackson.map.JsonMappingException: (was java.lang.NullPointerException) (through reference chain: org.ovirt.engine.api.model.Hosts["hosts"]->java.util.ArrayList[0]->org.ovirt.engine.api.model.Host["storageManager"]) at org.jboss.resteasy.core.ServerResponse.writeTo(ServerResponse.java:262) [resteasy-jaxrs-2.2.3.GA.jar:] at org.jboss.resteasy.core.SynchronousDispatcher.writeJaxrsResponse(SynchronousDispatcher.java:579) [resteasy-jaxrs-2.2.3.GA.jar:] at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:500) [resteasy-jaxrs-2.2.3.GA.jar:] at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119) [resteasy-jaxrs-2.2.3.GA.jar:] at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) [resteasy-jaxrs-2.2.3.GA.jar:] ... Version-Release number of selected component (if applicable): ovirt-engine git: 7353b27de3b182f1f6c511cbc9f1412743a377bb How reproducible: Always Steps to Reproduce: 1. Use REST Client for Firefox 2. Add request header: 'Accept: application/json' 3. Request URL /api/hosts Actual results: Internal server error: HTTP Status 500 - org.codehaus.jackson.map.JsonMappingException: (was java.lang.NullPointerException) (through reference chain: org.ovirt.engine.api.model.Hosts["hosts"]->java.util.ArrayList[0]->org.ovirt.engine.api.model.Host["storageManager"]) type Status report message org.codehaus.jackson.map.JsonMappingException: (was java.lang.NullPointerException) (through reference chain: org.ovirt.engine.api.model.Hosts["hosts"]->java.util.ArrayList[0]->org.ovirt.engine.api.model.Host["storageManager"]) description The server encountered an internal error (org.codehaus.jackson.map.JsonMappingException: (was java.lang.NullPointerException) (through reference chain: org.ovirt.engine.api.model.Hosts["hosts"]->java.util.ArrayList[0]->org.ovirt.engine.api.model.Host["storageManager"])) that prevented it from fulfilling this request. JBoss Web/7.0.3.Final Expected results: A JSON representation of the hosts collection. Additional info: