简体   繁体   English

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

[英]Amdatu + Jackson - Not Serializing ArrayList - RESTful Service with OSGi

I am writing a Hello World web-service, and got stuck trying to serialize/deserialize the class list returned. 我正在编写一个Hello World Web服务,并且在尝试序列化/反序列化返回的类列表时遇到了麻烦。

I have this code that is supposed to return a list of Conferences in Json: 我有此代码应返回Json中的Conferences列表:

@GET
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Description("lists conferences")
public List<Conference> list() {
    return agenda.listConferences();
}

Now, when I test the Service then I get this as response: 现在,当我测试服务时,将得到以下响应:

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

If I return the class Conference it works and returns the respective Json of the class, but if I make it return a list of conferences then it throws this exception. 如果我返回Conference类,则可以正常工作并返回该类的相应Json,但是如果我返回会议列表,则将引发此异常。

I am using these bundles to manage the RESTful service: 我正在使用这些捆绑包来管理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>

Anybody knows why? 有人知道为什么吗?

The reason is that you are using an old version of Amdatu Wink. 原因是您使用的是旧版本的Amdatu Wink。 The current version is 1.0.6. 当前版本是1.0.6。 Jackson support was not available yet in the version you are using. 您所使用的版本尚未提供Jackson支持。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM