Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing dependency for method when doing a file upload rest web service

Tags:

java

rest

jersey

I've been trying to understand how to fix this error:

SEVERE: Missing dependency for method public java.lang.String com.myrest.FileService.uploadFile(java.io.File,com.sun.jersey.core.header.FormDataContentDisposition) at parameter at index 0
SEVERE: Missing dependency for method public java.lang.String com.myrest.FileService.uploadFile(java.io.File,com.sun.jersey.core.header.FormDataContentDisposition) at parameter at index 1
SEVERE: Method, public java.lang.String com.myrest.FileService.uploadFile(java.io.File,com.sun.jersey.core.header.FormDataContentDisposition), annotated with POST of resource, class com.myrest.FileService, is not recognized as valid resource method.

I am working with a Apache Jersey based rest web service and doing a upload service.

Anyone have encountered this error before?

I am getting this error for this code:

    @POST
    @Path("/upload{path:.*}")
    @Consumes("multipart/form-data")
    @Produces("text/plain")
    public String uploadFile(
            @FormDataParam("file") File file, 
            @FormDataParam("file") FormDataContentDisposition fileDetail) {

        String fileLocation = "/files/" + fileDetail.getFileName();
        System.out.println("Copying file to : " + fileLocation);
        return "1";
    }
like image 292
quarks Avatar asked Dec 28 '11 16:12

quarks


Video Answer


1 Answers

In my case the problem were different library versions of jersey-bundle and com.sun.jersey.contribs; after settign both to the same version everything worked.

like image 175
Andreas Avatar answered Oct 01 '22 11:10

Andreas