6

I seem to have a missing dependency but can't find the solution... I've made sure all jersey versions are identical as answered here.

Error:

  SEVERE: The following errors and warnings have been detected with resource and/or provider classes:
  SEVERE: Missing dependency for method public abstract javax.ws.rs.core.Response com.service.copy(java.io.InputStream,com.sun.jersey.core.header.FormDataContentDisposition) at parameter at index 0

Dependencies used:

<dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-servlet</artifactId>
        <version>1.17</version>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey.contribs</groupId>
        <artifactId>jersey-multipart</artifactId>
        <version>1.17</version>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-json</artifactId>
        <version>1.17</version>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-bundle</artifactId>
        <version>1.17</version>
    </dependency> 

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

Code where the error happens:

@POST
@Path("copy")
public Response copy(@FormDataParam("file") InputStream uploadedInputStream,
            @FormDataParam("file") FormDataContentDisposition fileDetail);

Any ideas? Thanks a lot in advance, Frank

Community
  • 1
  • 1
Frank
  • 5,741
  • 4
  • 28
  • 49

2 Answers2

7

Yeah found it!

Apparently the dependencies were OK.

Added these to my imports

import javax.ws.rs.Consumes;
import javax.ws.rs.core.MediaType;

And changed the code to

@POST
@Path("copy")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response copy(@FormDataParam("file") InputStream uploadedInputStream,
            @FormDataParam("file") FormDataContentDisposition fileDetail);

And now suddenly everything works! So hope I can help someone else with the same problem...

Frank
  • 5,741
  • 4
  • 28
  • 49
3

@FormDataParam seems to be very fussy about the @Consumes annotation. Note that (unlike just about everything else) placing this annotation on an interface definition of the method isn't good enough for @FormDataParam !

Partly Cloudy
  • 6,508
  • 3
  • 27
  • 16