如何摆脱org.restlet.ext.jaxrs.internal.util.ExceptionHandler noMessageBodyWriter?

时间:2015-03-24 14:29:00

标签: java jax-rs restlet

我可以调用http://localhost/products并获取所需的XML输出。如果我致电http://localhost/facets,我会

Mar 24, 2015 3:10:50 PM org.restlet.ext.jaxrs.internal.util.ExceptionHandler noMessageBodyWriter
WARNING: No message body writer found for class com.galexis.search.productsearch.bean.facet.FacetsDTO(generic type is class com.galexis.search.productsearch.bean.facet.FacetsDTO); response media type should be: application/xml; accepted media types are: [[text/html, application/xhtml+xml], [application/xml], [*/*]] 

这是我的资源:

public class MyResource {

    @Path("products")
    @GET
    @Produces("application/xml")
    public ProductsDTO getProductsByFieldNamesAndSearchStrings(somme parameters) {

        return getProducts();
    }

    @Path("facets")
    @GET
    @Produces("application/xml")
    public FacetsDTO getProductsFacetByFieldNamesAndSearchStrings(somme parameters) {
        return getFacets();
    }

}

ProductsDTO

@XmlRootElement(name = "products")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType
public class ProductsDTO {
   ...
}

FacetsDTO

@XmlType
@XmlAccessorType(XmlAccessType.FIELD)
public class FacetsDTO {
   ...
}

知道缺少什么?

1 个答案:

答案 0 :(得分:0)

在进行了艰难的游览并调试了restlet jax-rs扩展后,我发现它检查了@XmlRootElement元素。如果没有,则拒绝提供application/xml答案。