users@glassfish.java.net

Glassfish 4.0 JAX-RS empty HTTP POST MultivaluedMap form parameters

From: <thezultimate_at_yahoo.com>
Date: Wed, 31 Jul 2013 09:45:52 +0000 (UTC)

Hi All,

I'd like to ask a question related to an issue I encountered with
Glassfish 4.0 Web application deployment.

I created a REST Web service application with JAX-RS and deployed it on
Glassfish 3.1.2 with no issue. Recently I tried deploying it on
Glassfish 4.0 and encountered a warning as follows.

A servlet request to the URI
http://localhost:8080/IipDev3/root/provider/publication/info:647254662
contains form parameters in the request body but the request body has
been consumed by the servlet or a servlet filter accessing the request
parameters. Only resource methods using @FormParam will work as
expected. Resource methods consuming the request body by other means
will not work as expected.

I use javax.ws.rs.core.MultivaluedMap to store the form parameters, but
it is indeed empty for HTTP POST requests. Strangely, it is not empty
for HTTP PUT requests. I have tried searching for solutions on the
Internet but got stuck (in the worst case I can fallback to Glassfish
3.1.2 deployment of course).

Code snippets:

@POST
@Path("publication/{infoId}")
@Consumes("application/x-www-form-urlencoded")
@Produces("application/xml")
public String publishToAnInformationChannel(@PathParam("infoId") String
infoId,
MultivaluedMap formParams, @Context SecurityContext sc) {
// formParams empty + warning
}

@PUT
@Path("registration/information/{infoId}")
@Consumes("application/x-www-form-urlencoded")
@Produces("application/xml")
public String updateAnInformationChannel(@PathParam("infoId") String
infoId,
MultivaluedMap formParams, @Context SecurityContext sc) {
// formParams filled in + no warning
}

If anyone knows how to solve this issue, please let me know. Thanks a
lot.

Best regards,
Dafferianto