SEVERE: A message body reader for Java class com.sun.jersey.multipart.FormDataMultiPart, and Java type class com.sun.jersey.multipart.FormDataMultiPart, and MIME media type multipart/form-data; boundary=Boundary_1_12258573_127987272668 was not found

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

SEVERE: A message body reader for Java class com.sun.jersey.multipart.FormDataMultiPart, and Java type class com.sun.jersey.multipart.FormDataMultiPart, and MIME media type multipart/form-data; boundary=Boundary_1_12258573_127987272668 was not found

sohit224
Hi,
I am using 1.5-ea9 jersey jars. I am getting following error

SEVERE: A message body reader for Java class com.sun.jersey.multipart.FormDataMultiPart, and Java type class com.sun.jersey.multipart.FormDataMultiPart, and MIME media type multipart/form-data; boundary=Boundary_1_12258573_127987272668 was not found
com.sun.jersey.spi.container.ContainerRequest getEntity
SEVERE: The registered message body readers compatible with the MIME media type are:
<<List>>

Here is the code used
-- Client Code

ClientConfig config = new DefaultClientConfig();
Client client = Client.create(config);
FormDataMultiPart fdmp = new FormDataMultiPart();
FormDataBodyPart fdp = new FileDataBodyPart("file", filename,MediaType.MULTIPART_FORM_DATA_TYPE);
fdmp.bodyPart(fdp);

WebResource service = client.resource(UriBuilder.fromUri(baseUrl).build())
                                .path("macd").path("uploadFileRequest")
                                .type("multipart/form-data"")
                                .post(ClientResponse.class, fdmp);
response.getEntity(String.class);

-- Server Code
@Path("uploadFileRequest")
public class WebServiceHandler {
               
        @POST
        @Consumes("multipart/form-data")
        public String handleMessage( FormDataMultiPart formData) {
        -- code
        }
}

-- Web.xml entry

<servlet>
 <servlet-name>jersey</servlet-name>
  <servlet-class> com.sun.jersey.spi.container.servlet.ServletContainer </servlet-class>
   <init-param>
    <param-name>com.sun.jersey.config.property.packages</param-name>
    <param-value>com.cisco.ca.ast.mpc.handler</param-value>
   </init-param>
  <load-on-startup>2</load-on-startup>
 </servlet>
 
<servlet-mapping>
 <servlet-name>jersey</servlet-name>
 <url-pattern>/macd/*</url-pattern>
</servlet-mapping>
Reply | Threaded
Open this post in threaded view
|

Re: SEVERE: A message body reader for Java class com.sun.jersey.multipart.FormDataMultiPart, and Java type class com.sun.jersey.multipart.FormDataMultiPart, and MIME media type multipart/form-data; boundary=Boundary_1_12258573_127987272668 was not found

Martin Matula-3
Hi,
Please make sure you have mimepull.jar on the classpath.
Martin

On Jan 28, 2011, at 10:38 AM, sohit224 wrote:

>
> Hi,
> I am using 1.5-ea9 jersey jars. I am getting following error
>
> SEVERE: A message body reader for Java class
> com.sun.jersey.multipart.FormDataMultiPart, and Java type class
> com.sun.jersey.multipart.FormDataMultiPart, and MIME media type
> multipart/form-data; boundary=Boundary_1_12258573_127987272668 was  
> not found
> com.sun.jersey.spi.container.ContainerRequest getEntity
> SEVERE: The registered message body readers compatible with the MIME  
> media
> type are:
> <<List>>
>
> Here is the code used
> -- Client Code
>
> ClientConfig config = new DefaultClientConfig();
> Client client = Client.create(config);
> FormDataMultiPart fdmp = new FormDataMultiPart();
> FormDataBodyPart fdp = new FileDataBodyPart("file",
> filename,MediaType.MULTIPART_FORM_DATA_TYPE);
> fdmp.bodyPart(fdp);
>
> WebResource service =  
> client.resource(UriBuilder.fromUri(baseUrl).build())
> .path("macd").path("uploadFileRequest")
> .type("multipart/form-data"")
> .post(ClientResponse.class, fdmp);
> response.getEntity(String.class);
>
> -- Server Code
> @Path("uploadFileRequest")
> public class WebServiceHandler {
>
> @POST
> @Consumes("multipart/form-data")
> public String handleMessage( FormDataMultiPart formData) {
> -- code
> }
> }
>
> -- Web.xml entry
>
> <servlet>
> <servlet-name>jersey</servlet-name>
>  <servlet-class> com.sun.jersey.spi.container.servlet.ServletContainer
> </servlet-class>
>   <init-param>
>    <param-name>com.sun.jersey.config.property.packages</param-name>
>    <param-value>com.cisco.ca.ast.mpc.handler</param-value>
>   </init-param>
>  <load-on-startup>2</load-on-startup>
> </servlet>
>
> <servlet-mapping>
> <servlet-name>jersey</servlet-name>
> <url-pattern>/macd/*</url-pattern>
> </servlet-mapping>
> --
> View this message in context: http://jersey.576304.n2.nabble.com/SEVERE-A-message-body-reader-for-Java-class-com-sun-jersey-multipart-FormDataMultiPart-and-Java-typed-tp5969276p5969276.html
> Sent from the Jersey mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: SEVERE: A message body reader for Java class com.sun.jersey.multipart.FormDataMultiPart, and Java type class com.sun.jersey.multipart.FormDataMultiPart, and MIME media type multipart/form-data; boundary=Boundary_1_12258573_127987272668 was not found

sohit224
Hi Martin,

Thanks for the quick reply.
Your solution worked.
But now i am facing another issue.

I am using tomcat 6.0.
While uploading small sized files (around 8-9 Kb) the upload is processing fine.
But with a larger upload i am getting Bad Request (HTTP 400) error.

I have used the client specified and a simple HTML form as well. Both are giving the same error.

Instead of using jersey-server, I tried the same using HttpServlet which worked.



Reply | Threaded
Open this post in threaded view
|

Re: SEVERE: A message body reader for Java class com.sun.jersey.multipart.FormDataMultiPart, and Java type class com.sun.jersey.multipart.FormDataMultiPart, and MIME media type multipart/form-data; boundary=Boundary_1_12258573_127987272668 was not found

Dave Brown
Make sure the Tomcat temp directory exists.


sohit224 <sohit224@...> writes:
>
> I am using tomcat 6.0.
> While uploading small sized files (around 8-9 Kb) the upload is processing
> fine.
> But with a larger upload i am getting Bad Request (HTTP 400) error.



Reply | Threaded
Open this post in threaded view
|

Re: SEVERE: A message body reader for Java class com.sun.jersey.multipart.FormDataMultiPart, and Java type class com.sun.jersey.multipart.FormDataMultiPart, and MIME media type multipart/form-data; boundary=Boundary_1_12258573_127987272668 was not found

Stephan Knull
Hello,

I have a similar problem with version 1.6. I previously used the following codes with version 1.1.5 which worked fine for me:

Here is the client side code:

      final WebResource resource = IntranetUtil.getJerseyClient().resource(baseUrl + "/theService");
      FormDataMultiPart formData;
      formData = new FormDataMultiPart();
      formData.field("schema", "THESCHEMA", MediaType.TEXT_PLAIN_TYPE);
      formData.field("table", "THETABLE", MediaType.TEXT_PLAIN_TYPE);
      formData.field("authUser", "THEUSER", MediaType.TEXT_PLAIN_TYPE);
      final String result = resource.type("multipart/form-data").post(String.class, formData);
      formData.close();
      return result;

And her the server side:

  @POST
  @Path("theService")
  @Consumes("multipart/form-data")
  public String theService(
  @DefaultValue("") @FormParam("schema") final String schema,
      @DefaultValue("") @FormParam("table") final String table,
      @DefaultValue("") @FormParam("authUser") final String authUser)
      throws Exception
  {
                ...
  }

In my "theService" method I could use the parameters "schema", "table", etc. directly as usual.
After switching to version 1.6 I have the problem, that on the server side all form fields are empty/not set now. I had to roll back to version 1.1.5 for now since this was production code.
How can I fix this (ofcourse I don't want to stay with that very old version)?

Kind regards
Stephan Knull
Reply | Threaded
Open this post in threaded view
|

Re: SEVERE: A message body reader for Java class com.sun.jersey.multipart.FormDataMultiPart, and Java type class com.sun.jersey.multipart.FormDataMultiPart, and MIME media type multipart/form-data; boundary=Boundary_1_12258573_127987272668 was not found

Pavel Bucek-2
Helle Stephan,

you should see something like:

...
May 3, 2011 1:15:23 PM
com.sun.jersey.server.impl.model.method.dispatch.MultipartFormDispatchProvider
getInjectables
SEVERE: Resource methods utilizing @FormParam and consuming
"multipart/form-data" are no longer supported. See @FormDataParam.
...

in your server log. When I changes @FormParam to @FormDataParam,
everything works as expected.

Regards,
Pavel


On 5/3/11 10:00 AM, Stephan Knull wrote:

> Hello,
>
> I have a similar problem with version 1.6. I previously used the following
> codes with version 1.1.5 which worked fine for me:
>
> Here is the client side code:
>
>        final WebResource resource =
> IntranetUtil.getJerseyClient().resource(baseUrl + "/theService");
>        FormDataMultiPart formData;
>        formData = new FormDataMultiPart();
>        formData.field("schema", "THESCHEMA", MediaType.TEXT_PLAIN_TYPE);
>        formData.field("table", "THETABLE", MediaType.TEXT_PLAIN_TYPE);
>        formData.field("authUser", "THEUSER", MediaType.TEXT_PLAIN_TYPE);
>        final String result =
> resource.type("multipart/form-data").post(String.class, formData);
>        formData.close();
>        return result;
>
> And her the server side:
>
>    @POST
>    @Path("theService")
>    @Consumes("multipart/form-data")
>    public String theService(
>     @DefaultValue("") @FormParam("schema") final String schema,
>        @DefaultValue("") @FormParam("table") final String table,
>        @DefaultValue("") @FormParam("authUser") final String authUser)
>        throws Exception
>    {
> ...
>    }
>
> In my "theService" method I could use the parameters "schema", "table", etc.
> directly as usual.
> After switching to version 1.6 I have the problem, that on the server side
> all form fields are empty/not set now. I had to roll back to version 1.1.5
> for now since this was production code.
> How can I fix this (ofcourse I don't want to stay with that very old
> version)?
>
> Kind regards
> Stephan Knull
>
> --
> View this message in context: http://jersey.576304.n2.nabble.com/SEVERE-A-message-body-reader-for-Java-class-com-sun-jersey-multipart-FormDataMultiPart-and-Java-typed-tp5969276p6326476.html
> Sent from the Jersey mailing list archive at Nabble.com.
>

Reply | Threaded
Open this post in threaded view
|

Re: SEVERE: A message body reader for Java class com.sun.jersey.multipart.FormDataMultiPart, and Java type class com.sun.jersey.multipart.FormDataMultiPart, and MIME media type multipart/form-data; boundary=Boundary_1_12258573_127987272668 was not found

Stephan Knull
Hi Pavel,

thanks for your very quick reply.
Even if I switch to debug level I can not see the stated log output.
Anyway - I changed the parameters to @FormDataParam for those methods using multipart.
Now everything works fine as promised - so you saved my day !

Kind Regards
Stephan Knull
Reply | Threaded
Open this post in threaded view
|

Re: SEVERE: A message body reader for Java class com.sun.jersey.multipart.FormDataMultiPart, and Java type class com.sun.jersey.multipart.FormDataMultiPart, and MIME media type multipart/form-data; boundary=Boundary_1_12258573_127987272668 was not found

adnan.maks
I have mimepull.jar in my classpath and I still face the same issue. Plz help- it's urgent that this POC gets underway so we implement it in our project.

Server code -

@Path("/fileTransfer")
public class FileTransferServer {
       
        @POST
        @Consumes(MediaType.MULTIPART_FORM_DATA)
        @Produces(MediaType.APPLICATION_XML)
        public String fileTransferInviteMultiPart(FormDataMultiPart data) throws IOException {
                return "success";
        }
}

client code -


ClientConfig config = new DefaultClientConfig();
                config.getClasses().add(MultiPartWriter.class);
                Client client = Client.create(config);
                client.setChunkedEncodingSize(1024*1024);
                WebResource service = client.resource(getBaseURI());
               
                File veryLargeFile = new File("D:/dummy.txt");
                FormDataMultiPart formData = new FormDataMultiPart();
               
                if (veryLargeFile != null) {
                        formData.bodyPart(new FormDataBodyPart("file1_metadata", "this is file metadata", MediaType.MULTIPART_FORM_DATA_TYPE));
                        formData.bodyPart(new FileDataBodyPart("file1", veryLargeFile, MediaType.APPLICATION_OCTET_STREAM_TYPE));
                }
               
                String xmlString = service.path("rest").path("fileTransfer").type(MediaType.MULTIPART_FORM_DATA).accept(MediaType.APPLICATION_XML).post(String.class,formData);
                System.out.println(xmlString);