Neo4j - 在非托管扩展中返回JSON中的Collection对象

时间:2012-08-13 20:45:56

标签: json neo4j

我为Neo4j编写了一个非托管扩展,我需要它来返回一个Collection(我有一个Set),并希望以JSON方式返回它,但是当我尝试返回我得到的对象时

SEVERE: A message body writer for Java class java.util.ArrayList, and Java type class java.util.ArrayList, and MIME media type application/json was not found
Aug 14, 2012 8:56:51 AM com.sun.jersey.spi.container.ContainerResponse write
SEVERE: The registered message body writers compatible with the MIME media type are:
*/* ->
  com.sun.jersey.core.impl.provider.entity.FormProvider
  com.sun.jersey.core.impl.provider.entity.StringProvider
  com.sun.jersey.core.impl.provider.entity.ByteArrayProvider
  com.sun.jersey.core.impl.provider.entity.FileProvider
  com.sun.jersey.core.impl.provider.entity.InputStreamProvider
  com.sun.jersey.core.impl.provider.entity.DataSourceProvider
  com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$General
  com.sun.jersey.core.impl.provider.entity.ReaderProvider
  com.sun.jersey.core.impl.provider.entity.DocumentProvider
  com.sun.jersey.core.impl.provider.entity.StreamingOutputProvider
  com.sun.jersey.core.impl.provider.entity.SourceProvider$SourceWriter
  com.sun.jersey.server.impl.template.ViewableMessageBodyWriter
  com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$General
  com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General

javax.ws.rs.WebApplicationException: com.sun.jersey.api.MessageException: A message body writer for Java class java.util.HashSet, and Java type class java.util.HashSet, and MIME media type application/json was not found

我的Java代码是

Set<Long> matches = new HashSet<Long>();
return Response.ok(matches, MediaType.APPLICATION_JSON).build();

我认为它会处理列表,但从上面的错误中我可以看到它没有。这在Neo4j非托管扩展中是否可行

0 个答案:

没有答案