Resteasy 3.0.9.Final NoMessageBodyWriterFoundFailure

时间:2015-06-03 10:04:33

标签: java jaxb resteasy

使用RestEasy 3.0.9.Final以及3.0.11.Final 时,抛出此错误:

org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure: Could not find MessageBodyWriter for response object of type: [Lmodels.Person; of media type: application/json
    at org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse(ServerResponseWriter.java:67)

我读过ELSEWHERE是因为Jaxb。

 <dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-jaxrs</artifactId>
    <version>${resteasy.version}</version>
    <exclusions>
        <exclusion>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
        </exclusion>
    </exclusions>
</dependency>          
<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-jaxb-provider</artifactId>
    <version>${resteasy.version}</version>
</dependency> 

我还尝试过这种依赖,而不仅仅是jaxb

<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-jettison-provider</artifactId>
    <version>${resteasy.version}</version>
</dependency>                
<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-jackson-provider</artifactId>
    <version>${resteasy.version}</version>
</dependency>                        

实际上,以下代码之前没有错误

@Path("/persons")
public class PersonController {
...
    @GET
    @Consumes({"application/json", "application/xml"})
    @Produces({"application/json", "application/xml"})
    public Person[] get() {
        //log.info("Getting all Person");
        return database.currentList();
    }
}

@XmlRootElement(name = "Person")
public class Person {
    private String pid;
    private String name;
    public Person() {
    }

    @XmlElement
    public String getName() {
        return name;
    }

    @XmlElement
    public String getPid() {
        return pid;
    }
... // with other setters and getters also.
}

不太确定为什么突然间它现在无法正常工作。

0 个答案:

没有答案