Skip to main content

Glassfish 4.0 JAX-RS empty HTTP POST MultivaluedMap form parameters

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
No replies
thezultimate
Offline
Joined: 2009-07-14

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