我得到了:
org.jboss.resteasy.plugins.providers.jaxb.JAXBMarshalException: Could not find JAXBContextFinder for media type: application/json
at org.jboss.resteasy.plugins.providers.jaxb.AbstractJAXBProvider.findJAXBContext(AbstractJAXBProvider.java:50)
at org.jboss.resteasy.plugins.providers.jaxb.AbstractJAXBProvider.getMarshaller(AbstractJAXBProvider.java:127)
在客户端...我有以下pom.xml,你可以看到jettison jaxb提供程序以及jettison核心jar:
<repositories>
<repository>
<id>jboss</id>
<url>http://repository.jboss.org/maven2</url>
</repository>
<repository>
<id>maven</id>
<url>http://mvnrepository.com//maven2</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>5.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.34</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>jstl-api</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>5.1</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>3.0.2.Final</version>
</dependency>
<!-- JAXB support -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxb-provider</artifactId>
<version>3.0.2.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>jaxrs-api</artifactId>
<version>3.0.2.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>3.0.2.Final</version>
</dependency>
<dependency>
<groupId>net.sf.scannotation</groupId>
<artifactId>scannotation</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jettison-provider</artifactId>
<version>3.0.10.Final</version>
</dependency>
<dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
<version>1.3.7</version>
</dependency>
</dependencies>
在我的客户端调用中使用的用户DTO中,我有XmlRootElement注释,调用是:
public UserDTO getUserData(String userName) {
webTarget = client.target(BASE_URI).path("Login/GetUserData");
Form form = new Form();
form.param("userName", userName);
Response requestResult;
Entity<Form> entity;
MediaType sent = MediaType.APPLICATION_FORM_URLENCODED_TYPE;
entity = Entity.entity(form, sent);
MediaType [] accepted = {MediaType.APPLICATION_JSON_TYPE};
requestResult = webTarget.request(accepted)
.post(entity);
UserDTO result = (UserDTO)requestResult.getEntity();
return result;
}
任何想法?
答案 0 :(得分:0)
根据resteasy 3.0.2 jettison example,您不需要resteasy-jaxb-provider依赖。我认为这包括在resteasy-jettison-provider中。
查看是否删除了resteasy-jaxb-provider依赖项,并将resteasy-jettison-provider版本更新为3.0.2有助于..