Mapped exception to response: 500 (Internal Server Error)

严重: A message body writer for Java class java.util.Collections$SingletonList, and Java type java.util.Collection, and MIME media type application/json was not found

2012-7-12 13:55:32 com.sun.jersey.spi.container.ContainerResponse write

严重: 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

  

2012-7-12 13:55:32 com.sun.jersey.spi.container.ContainerResponse logException

严重: Mapped exception to response: 500 (Internal Server Error)

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

 at com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:285)

 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)

 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)

 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)

 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)

 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)

 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)

 at java.lang.Thread.run(Thread.java:619)

Caused by: com.sun.jersey.api.MessageException: A message body writer for Java class java.util.Collections$SingletonList, and Java type java.util.Collection, and MIME media type application/json was not found

第一个可能的解决方案:

可能存在不同版本的jar包共存,删除其一;

第二个可能的解决方案:

相应的bean需要加上注解@XmlRootElement()

你可能感兴趣的:(exception)