无法使用Multipart将QueryDto的实例反序列化为START_ARRAY标记

时间:2014-04-25 06:58:43

标签: json rest jackson

我在Rest服务中有两种方法:

@Path("judgements")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
public interface JudgementsService {
  @POST
  @Path("get1")
  @Consumes(MediaType.APPLICATION_JSON)
  void test(Set<Query> param) throws IOException;

  @POST
  @Path("get")
  Map<Query, JudgementsForQuery> getJudgementsForQueries(
          @Multipart(value = "queries", type = MediaType.APPLICATION_JSON) Set<Query> queries,
          @Multipart(value = "regional", type = MediaType.APPLICATION_JSON) RegionalType regionalType,
          @Multipart(value = "evaluation", type = MediaType.APPLICATION_JSON) EvaluationType evaluationType) throws IOException;

方法test()工作正常,方法getJudgementsForQueries()抛出异常:

2014-04-25 10:46:56,600 ERROR [main] r.y.q.b.e.ServerExceptionMapper - Can not deserialize instance of ru.yandex.qe.model.dto.QueryDto out of START_ARRAY token
 at [Source: org.apache.cxf.attachment.DelegatingInputStream@2e5667ed; line: 1, column: 1]
com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of ru.yandex.qe.model.dto.QueryDto out of START_ARRAY token
 at [Source: org.apache.cxf.attachment.DelegatingInputStream@2e5667ed; line: 1, column: 1]
    at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:164) ~[jackson-databind-2.2.2.jar:2.2.2]
    at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:575) ~[jackson-databind-2.2.2.jar:2.2.2]
    at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:569) ~[jackson-databind-2.2.2.jar:2.2.2]
    at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromArray(BeanDeserializerBase.java:1121) ~[jackson-databind-2.2.2.jar:2.2.2]
    at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:148) ~[jackson-databind-2.2.2.jar:2.2.2]
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:123) ~[jackson-databind-2.2.2.jar:2.2.2]
    at com.fasterxml.jackson.databind.ObjectReader._bind(ObjectReader.java:1179) ~[jackson-databind-2.2.2.jar:2.2.2]
    at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:635) ~[jackson-databind-2.2.2.jar:2.2.2]
    at com.fasterxml.jackson.jaxrs.base.ProviderBase.readFrom(ProviderBase.java:587) ~[jackson-jaxrs-base-2.2.2.jar:2.2.2]

由于某些原因似乎json打包成多部分消息并没有正确地映射到集合......

任何帮助表示赞赏!!

0 个答案:

没有答案