简体   繁体   中英

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.

I have this code that is supposed to return a list of Conferences in Json:

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

I am using these bundles to manage the RESTful service:

  <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. The current version is 1.0.6. Jackson support was not available yet in the version you are using.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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