如何摆脱 org.restlet.ext.jaxrs.internal.util.ExceptionHandler MessageBodyWriter?
How to get rid of org.restlet.ext.jaxrs.internal.util.ExceptionHandler noMessageBodyWriter?
我可以打电话http://localhost/products and get the desired XML output. If I call 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();
}
}
产品DTO
@XmlRootElement(name = "products")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType
public class ProductsDTO {
...
}
FacetsDTO
@XmlType
@XmlAccessorType(XmlAccessType.FIELD)
public class FacetsDTO {
...
}
知道缺少什么吗?
经过艰难的探索和调试 restelt jax-rs 扩展后,我发现它会检查 @XmlRootElement
元素。如果它不存在,它拒绝服务器 application/xml
答案。
我可以打电话http://localhost/products and get the desired XML output. If I call 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();
}
}
产品DTO
@XmlRootElement(name = "products")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType
public class ProductsDTO {
...
}
FacetsDTO
@XmlType
@XmlAccessorType(XmlAccessType.FIELD)
public class FacetsDTO {
...
}
知道缺少什么吗?
经过艰难的探索和调试 restelt jax-rs 扩展后,我发现它会检查 @XmlRootElement
元素。如果它不存在,它拒绝服务器 application/xml
答案。