users@jersey.java.net

[Jersey] Issue with receiving a POSTed multipart/mixed

From: Jeff Hagen <jeff.hagen_at_oracle.com>
Date: Wed, 24 Apr 2013 19:09:49 -0700

Hello,

I'm beating my head against the wall here so I figured that asking a question is probably a good idea.

I'm having some difficulty getting my Jersey server to accept a POSTed multipart/mixed message.

I am getting the following error (with redactions)

"
INFO: Root resource classes found:
  class xxx.xxx.xxx.xxx.xxx.myResource
...

SEVERE: A message body reader for Java class com.sun.jersey.multipart.MultiPart, and Java type class com.sun.jersey.multipart.MultiPart, and MIME media type application/octet-stream was not found.
The registered message body readers compatible with the MIME media type are:
application/octet-stream ->
  com.sun.jersey.core.impl.provider.entity.ByteArrayProvider
  com.sun.jersey.core.impl.provider.entity.FileProvider
..."

Google tells me that this is resolved by adding a few dependencies.

Here are the dependencies I already have as listed in my pom.xml
    <dependency>
      <groupId>com.sun.jersey.contribs</groupId>
      <artifactId>jersey-multipart</artifactId>
      <version>1.12</version>
    </dependency>

    <dependency>
      <groupId>org.jvnet</groupId>
      <artifactId>mimepull</artifactId>
      <version>1.6</version>
    </dependency>

I checked to make sure that the classes are actually on the class path:
$ ls target/dependencies/jersey-multipart*
target/dependencies/jersey-multipart-1.12.jar
$ ls target/dependencies/mimepull*
target/dependencies/mimepull-1.6.jar

They do appear to be on the classpath of the deployed application, however the error remains.

The code in question looks like this:

...
import javax.ws.rs.core.Context;
import com.sun.jersey.multipart.MultiPart;
...

@Path("/batch")
public class MyResource
{

 ...
   public BaseResource()
  {
    this.log = Logger.getLogger(this.getClass());
    log.debug("Creating a myResource");
  }

  @POST
  @Consumes("multipart/mixed")
  public Response postHandler(MultiPart body,
                              @Context HttpHeaders hh,
                              @Context UriInfo uriInfo)
    throws Exception
  {
    return a_function_call(...);
  }

Any ideas?

Thanks!
-Jeff