[英]NoMessageBodyWriterFoundFailure when trying to access pojo
I'm trying to migrate a webservice project to resteasy from jersey, and I'm getting a strange error: 我正在尝试将Web服务项目从jersey迁移到resteasy,但遇到一个奇怪的错误:
ERROR [org.jboss.resteasy.resteasy_jaxrs.i18n] (default task-42) RESTEASY002005: Failed executing GET /directors/tmlist/dirUsr: org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure: Could not find MessageBodyWriter for response object of type: com.company.sales.beans.Resource of media type: application/json
Everything I've been able to find online has told me that I need to add an annotation to the pojo causing the problem, but it doesnt seem to have made any kind of difference. 我在网上可以找到的所有信息都告诉我,我需要在引起问题的pojo中添加注释,但似乎没有任何区别。
The pojo I'm working with is: 我正在使用的pojo是:
package com.company.sales.beans;
import javax.xml.bind.annotation.*;
import java.util.List;
@XmlRootElement
public class Resource<T> {
@XmlAnyElement(lax = true)
@XmlElement(name = "content")
private List<T> m_Content;
@XmlAttribute(name = "type")
private String m_Type;
@XmlAttribute(name = "src")
private String m_Source;
@XmlElementRef(name = "links")
private List<Link> m_Links;
/**
*
*/
public Resource() {
m_Content = null;
m_Type = null;
m_Source = null;
}
/**
* @return the m_Content
*/
public List<T> getContent() {
return m_Content;
}
/**
* @param m_Content the m_Content to set
*/
public void setContent(List<T> m_Content) {
this.m_Content = m_Content;
}
/**
* @return the m_Type
*/
public String getType() {
return m_Type;
}
/**
* @param m_Type the m_Type to set
*/
public void setType(String m_Type) {
this.m_Type = m_Type;
}
/**
* @return the m_Source
*/
public String getSource() {
return m_Source;
}
/**
* @param m_Source the m_Source to set
*/
public void setSource(String m_Source) {
this.m_Source = m_Source;
}
/**
* @return the m_Links
*/
public List<Link> getLinks() {
return m_Links;
}
/**
* @param m_Links the m_Links to set
*/
public void setLinks(List<Link> m_Links) {
this.m_Links = m_Links;
}
}
This was created by a previous employee at the company I work for and as far as I can tell was working fine with the previous library they were using (jersey 1.17). 它是由我工作过的公司的一位前员工创建的,据我所知,它与他们正在使用的前一个库(球衣1.17)工作得很好。 I'm not entirely sure why resteasy is still complaining about the missing message body writer, as I've found a few different sites claiming adding the @XmlRootElement should make it default to some built in writer/reader. 我不完全确定为什么resteasy仍然抱怨缺少的消息正文编写器,因为我发现一些不同的站点声称添加@XmlRootElement应该使其默认为某些内置的编写器/阅读器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.