Marco Andreolli
Marco Andreolli

Reputation: 376

RESTfull Jersey application error in executable 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

Upvotes: 2

Views: 2942

Answers (1)

Pavel Bucek
Pavel Bucek

Reputation: 5324

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).

Upvotes: 5

Related Questions