Maven jersey-multipart missing dependency for javax.ws.rs.core.Response

16,496

Solution 1

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...

Solution 2

@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 !

Share:
16,496
Frank
Author by

Frank

Author of "Getting started with Java on the Raspberry Pi" https://leanpub.com/gettingstartedwithjavaontheraspberrypi/ Software developer at Toadi (Belgium) Lead Coach at CoderDojo Belgium Ieper Particularly interested in client/server and relational database design using MSSQL/MySql Server, digital signage, user experience,... Specialized in integration of different systems in one easy-to-use system. XML, HTML, JavaScript, usability, CSS, C#, Java, Python, Flex, Actionscript, ERP Solutions, Multimedia authoring, ...

Updated on June 05, 2022

Comments

  • Frank
    Frank almost 2 years

    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