Amdatu + Jackson - 没有序列化ArrayList - OSGi的RESTful服务

时间:2013-11-16 19:24:24

标签: jaxb osgi jackson amdatu

我正在编写一个 Hello World 网络服务,并试图序列化/反序列化返回的类列表。

我有这个代码应该在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>

有谁知道为什么?

1 个答案:

答案 0 :(得分:1)

原因是您使用的是旧版Amdatu Wink。目前的版本是1.0.6。您正在使用的版本中尚未提供Jackson支持。