Hi Pavel,
I'm seeing a similar exception with Multipart sending code (from iOS) that used to work fine with Jersey < 1.5. Upgrading to Glassfish 3.1.1 (Jersey 1.9.1) has broken this and resulted in my receiving HTTP 400.
How can I turn on Hersey logs so I can see more detail of the problem?
Ronak
________________________________
From: Pavel Bucek <pavel.bucek_at_oracle.com>
To: users_at_jersey.java.net
Sent: Thursday, December 8, 2011 7:03 AM
Subject: [Jersey] Re: @FormDataParam gives Bad Request.
Right.
1) are you sure you are sending "multipart/form-data"? Can you dump your request (with wireshark / something similar) and share it?
2) see @FormParam javadoc:
http://jersey.java.net/nonav/apidocs/latest/jersey/javax/ws/rs/FormParam.html. I've found simple sample using this funcionality:
http://www.mkyong.com/webservices/jax-rs/jax-rs-formparam-example/
3) @FormDataParam is used for handling multipart queries, see mutlipart spec:
http://www.ietf.org/rfc/rfc2388.txt. You'll need to have jersey-multipart module present on your classpath (you most likely do if you are using glassfish). You can check our sample - multipart-webapp [1] (linking version 1.4; it should be present in jersey-docs-and-samples glassfish IPS package, so you might already have that installed), please note test classes, they show how to call these REST resources from java (using jersey client).
I asked for server log, because there should be logged some exception / explanation declaring *why* was that request considered bad. I would start there..
Pavel
[1]
http://search.maven.org/#artifactdetails%7Ccom.sun.jersey.samples%7Cmultipart-webapp%7C1.4%7Cwar
On 12/8/11 5:18 AM, kavita wrote:
> eh? Glassfish 3.1 can run on jdk 1.6, not sure about 1.7 but I guess it
> should run.. anyway, that sentence doesn't make much sense. @FormParam
> is present in JAX-RS 1.x API so you don't need to replace it with
> anything, it is just there and it should work.
>>> Actually I have upgraded to java 7. I was using 1.6 update 7 which needed
>>> to be at least update 22. If i use @FormParam with jdk 1.7 it gives the
>>> error that @FormParam cannot be used for multipart/formdata. Nevertheless
>>> I will download the 22 update and use it with glassfish 3.1. Still I dont
>>> know what must be used for sending the request in case someone uses
>>> @FormDataParam!!!
>
> can you please look into server log (and let us know what you found
> there)? And is it possible for you to share service code as well?
>>> Sure this is the signature of the method:
> @POST
> @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
> @Consumes(MediaType.MULTIPART_FORM_DATA)
> public Exceldatalist getJson(@FormParam("purpose") String purpose,
> @FormDataParam("filename") String wbkname,
> @FormDataParam("username") String username,
> @FormDataParam("password") String pwd,
> @FormDataParam("company") String company)
> {
> System.out.println("Purpose: "+purpose);
> System.out.println("wbkname: "+wbkname);
> System.out.println("username: "+username);
> System.out.println("pwd: "+pwd);
> System.out.println("company: "+company);
> .
> .
> .
> .
> .
> }
>
> I've already said that the multipart jars loading which used to come on
> server.log whenever deploying such web services, does not come now with
> glassfish 3.1. But I can see the jars in the buildpath. jersey multipart 1.4
> is on the buildpath.
>
> I am getting a bad request resonse. I have given the log trace already.
> Please help me with this...
> Kavita
>
>
> --
> View this message in context: http://jersey.576304.n2.nabble.com/FormDataParam-gives-Bad-Request-tp7065882p7073213.html
> Sent from the Jersey mailing list archive at Nabble.com.
>