users@jersey.java.net

Re: [Jersey] issue with POST when packaging into jar

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Wed, 25 Aug 2010 11:54:50 +0200

Hi Varnit,

The problem is the META-INF/services files are not getting merged
correctly when you create the "uber" jar

I recommend using the maven shade plugin:

   http://maven.apache.org/plugins/maven-shade-plugin/

and also take not of configuration to concatenate META-INF/services
files:

http://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html

Paul.

On Aug 24, 2010, at 7:54 PM, Varnit Khanna wrote:

> Having a strange issue, using jersey 1.3 with grizzly 1.9.18 and have
> the following code:
>
> @Path("/v1/profile")
> public class ProfileResource extends BaseResource {
> .....
>
> @POST
> @Path("/create")
> @Consumes("application/x-www-form-urlencoded")
> @Produces("application/json")
> public Response createProfile(MultivaluedMap<String, String>
> formParams) {
> ...
>
> things work fine if run via maven:
> mvn clean compile exec:java
>
> using curl: curl -v -i -X POST --data "name=blah......"
> http://localhost:4080/v1/profile/create
>
> However when I package it into a jar using maven-assembly-plugin
> jar-with-dependencies things break with POST only, get the following
> error:
>
> Aug 24, 2010 1:33:59 PM
> com.sun.jersey.spi.container.ContainerRequest getEntity
> SEVERE: A message body reader for Java class
> javax.ws.rs.core.MultivaluedMap, and Java type
> javax.ws.rs.core.MultivaluedMap<java.lang.String, java.lang.String>,
> and MIME media type application/x-www-for
> m-urlencoded was not found
> Aug 24, 2010 1:33:59 PM
> com.sun.jersey.spi.container.ContainerRequest getEntity
> SEVERE: The registered message body readers compatible with the MIME
> media type are:
> */* ->
> com.sun.jersey.json.impl.provider.entity.JSONJAXBElementProvider
> $General
> com.sun.jersey.json.impl.provider.entity.JSONArrayProvider$General
> com.sun.jersey.json.impl.provider.entity.JSONObjectProvider$General
> com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider
> $General
> com.sun.jersey.json.impl.provider.entity.JSONListElementProvider
> $General
>
>
> Anyone have any ideas?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>