Java org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure:找不到媒体类型为application/xml的类型为的响应对象的MessageBodyWriter

Java org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure:找不到媒体类型为application/xml的类型为的响应对象的MessageBodyWriter,java,resteasy,Java,Resteasy,在我的*.ear中,我可以看到resteasy-jaxb-provider-2.2.0.GA.jar和resteasy-jaxrs-2.2.1.GA.jar都存在,但在尝试访问此方法时,我遇到了以下错误: [org.jboss.resteasy.core.SynchronousDispatcher] (http-/0.0.0:8080-1)执行POST失败 //getmethod: org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure:无

在我的*.ear中,我可以看到resteasy-jaxb-provider-2.2.0.GA.jar和resteasy-jaxrs-2.2.1.GA.jar都存在,但在尝试访问此方法时,我遇到了以下错误:

[org.jboss.resteasy.core.SynchronousDispatcher] (http-/0.0.0:8080-1)执行POST失败 //getmethod: org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure:无法 查找MessageBodyWriter以获取类型为:*媒体VO的响应对象 类型:application/xml位于 org.jboss.resteasy.core.ServerResponse.writeTo(ServerResponse.java:216) [resteasy-jaxrs-2.3.3.Final-redhat-1.jar:2.3.3.Final-redhat-1]

org.jboss.resteasy.core.SynchronousDispatcher.writejaxrssresponse(SynchronousDispatcher.java:585)

[resteasy-jaxrs-2.3.3.Final-redhat-1.jar:2.3.3.Final-redhat-1] org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:506) [resteasy-jaxrs-2.3.3.Final-redhat-1.jar:2.3.3.Final-redhat-1] org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119) [resteasy-jaxrs-2.3.3.Final-redhat-1.jar:2.3.3.Final-redhat-1] org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) [resteasy-jaxrs-2.3.3.Final-redhat-1.jar:2.3.3.Final-redhat-1] org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) [resteasy-jaxrs-2.3.3.Final-redhat-1.jar:2.3.3.Final-redhat-1] org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) [resteasy-jaxrs-2.3.3.Final-redhat-1.jar:2.3.3.Final-redhat-1] javaservlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.1.Final-redhat-1.jar:1.0.1.Final-redhat-1] 在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.16.Final-redhat-1.jar:] org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.16.Final-redhat-1.jar:] org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.16.Final-redhat-1.jar:] org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.16.Final-redhat-1.jar:] org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.2.Final-redhat-1.jar:7.1.2.Final-redhat-1] org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.16.Final-redhat-1.jar:] org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.16.Final-redhat-1.jar:] org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.16.Final-redhat-1.jar:] org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.16.Final-redhat-1.jar:] org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.16.Final-redhat-1.jar:] org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:679) [jbossweb-7.0.16.Final-redhat-1.jar:] org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:931) [jbossweb-7.0.16.Final-redhat-1.jar:]位于java.lang.Thread.run(未知) 来源)[rt.jar:1.7.0_09]


我没有在VO类属性中添加注释

样本:

@POST
@Path("/getmethod")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_XML)
Response getMethod(SomeVO someVO);

您可以通过参考下面的链接来解决此问题。。他建议补充一点 org.jboss.resteasy resteasy jaxb提供程序 2.2.0.GA 罐子

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "user")
public class TestVo {

    String order;
    String serial;
    int number;

    @XmlElement
    public String getorder() {
        return order;
    }

    public void setorder(String order) {
        this.order = order;
    }

    @XmlElement
    public String getserial() {
        return serial;
    }

    public void setserial(String serial) {
        this.serial = serial;
    }

    @XmlAttribute
    public int getnumber() {
        return number;
    }

    public void setnumber(int number) {
        this.number = number;
    }

}