可执行 jar 中的 RESTfull Jersey 应用程序错误
我制作了一个简单的 REST Jersey 应用程序,从 maven jersey-quickstart-grizzly 原型开始(来自 http://download.java .net/maven/2)。
如果我使用 maven 命令(mvncompileexec:java)运行它,它就可以正常工作;但如果我制作了一个可执行的 jar,它会返回以下错误:
11-nov-2011 10.58.33 com.sun.jersey.spi.container.ContainerResponse logException
GRAVE: Mapped exception to response: 500 (Internal Server Error)
javax.ws.rs.WebApplicationException: com.sun.jersey.api.MessageException: A mess
age body writer for Java class java.lang.String, and Java type class java.lang.S
tring, and MIME media type text/plain was not found
我尝试使用 assemble 和 shade 插件制作 jar,在任何一种情况下我都会遇到同样的问题。
我用谷歌搜索了很多,发现很多人都有同样的问题,但仍然没有解决方案
I made a simple REST Jersey application starting with maven jersey-quickstart-grizzly archetype (from http://download.java.net/maven/2).
It works fine if I run that with maven command (mvn compile exec:java); but if I made a single executable jar it return the following error:
11-nov-2011 10.58.33 com.sun.jersey.spi.container.ContainerResponse logException
GRAVE: Mapped exception to response: 500 (Internal Server Error)
javax.ws.rs.WebApplicationException: com.sun.jersey.api.MessageException: A mess
age body writer for Java class java.lang.String, and Java type class java.lang.S
tring, and MIME media type text/plain was not found
I try to made the jar with assembly and shade plugin and in either case I have the same problem.
I've googled a lot and I found many people have the same issue but still not a solution
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有正确合并 META-INF/services/* 文件。解决这个问题就可以了。
(当您合并两个或多个 jar 时,您需要添加内容,而不是替换。实际问题是您的 META-INF 中没有“com.sun.jersey.core.impl.provider.entity.StringProvider”行/services/javax.ws.rs.ext.MessageBodyReader 文件)。
You are not correctly merging META-INF/services/* files. Fix that and it will work.
(You need to add content when you are merging two or more jars, not replace. Actual problem is that you don't have "com.sun.jersey.core.impl.provider.entity.StringProvider" line in your META-INF/services/javax.ws.rs.ext.MessageBodyReader file).