Jersey: com.sun.jersey.server.impl.template.ViewableMessageBodyWriter

拟墨画扇 提交于 2019-12-08 00:39:23

问题


I'm totally alien to Jersey. I'm trying to run a jar which throws javax.ws.rs.WebApplicationException when I hit the endpoint. The error thrown by the program is as follows:

09-Apr-2011 08:32:20 com.sun.jersey.spi.container.ContainerResponse write

SEVERE: A message body writer for Java class java.lang.String, and Java type class java.lang.String, and MIME media type application/json was not found

09-Apr-2011 08:32:20 com.sun.jersey.spi.container.ContainerResponse write

SEVERE: The registered message body writers compatible with the MIME media type are: / -> com.sun.jersey.server.impl.template.ViewableMessageBodyWriter

09-Apr-2011 08:32:20 com.sun.jersey.spi.container.ContainerResponse logException

Any ideas for where to start looking at for debugging?

Update: I've got javax.ws.rs.ext.MessageBodyWriter in the META-INF/services of the jar with the following content: com.sun.jersey.server.impl.template.ViewableMessageBodyWriter

And at the beginning of the program I see: com.sun.jersey.server.impl.application.WebApplicationImpl _initiate


回答1:


You need to include jersey-json module on your class path - see the Jersey dependencies page, which has a list of dependencies you need to include based on the type of functionality you need: http://jersey.java.net/nonav/documentation/latest/chapter_deps.html



来源:https://stackoverflow.com/questions/5603921/jersey-com-sun-jersey-server-impl-template-viewablemessagebodywriter

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!