0

我正在编写一个Hello World Web 服务,但在尝试序列化/反序列化返回的类列表时遇到了困难。

我有这段代码应该Conferences在 Json 中返回一个列表:

@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>

有人知道为什么吗?

4

1 回答 1

1

原因是您使用的是旧版本的 Amdatu Wink。当前版本是 1.0.6。在您使用的版本中,Jackson 支持尚不可用。

于 2013-11-24T21:47:31.180 回答