我正在写一个Hello服务,并且被困在试图序列化/反序列化返回的类列表上。
我的代码应该返回Json中的Conferences列表:
@GET
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Description("lists conferences")
public List<Conference> list() {
return agenda.listConferences();
}现在,当我测试服务时,我会得到以下响应:
SEVERE: The system could not find a javax.ws.rs.ext.MessageBodyWriter or a DataSourceProvider class for the java.util.ArrayList type and application/json mediaT
ype. Ensure that a javax.ws.rs.ext.MessageBodyWriter exists in the JAX-RS application for the type and media type specified.
Nov 16, 2013 2:49:00 PM org.apache.wink.server.internal.RequestProcessor logException
INFO: The following error occurred during the invocation of the handlers chain: WebApplicationException (500 - Internal Server Error) with message 'null' while
processing GET request sent to http://localhost:8080/conferences如果我返回类Conference,它工作并返回类的各自Json,但是如果我让它返回一个会议列表,那么它会抛出这个异常。
我使用这些包来管理RESTful服务:
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
<version>1.9.13</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.13</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>
<dependency>
<groupId>org.amdatu.web</groupId>
<artifactId>org.amdatu.web.rest.wink</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>org.amdatu.web</groupId>
<artifactId>org.amdatu.web.rest.jaxrs</artifactId>
<version>1.0.0</version>
</dependency>有人知道为什么吗?
发布于 2013-11-24 21:47:31
原因是您使用的是一个旧版本的Amdatu。目前的版本是1.0.6。在您使用的版本中还没有杰克逊支持。
https://stackoverflow.com/questions/20022731
复制相似问题