title: Missing dependency for method public javax.ws.rs.core.Response (Upload File JAX-RS)
body: <p>I found an error when create method POST for upload file function. how to solve this problem? Thanks.</p>
  
  <p>this log error:</p>
  
  <blockquote>
    <p>Jul 05, 2017 4:20:23 PM org.apache.coyote.AbstractProtocol init INFO:
    Initializing ProtocolHandler ["http-bio-8087"] Jul 05, 2017 4:20:23 PM
    org.apache.catalina.core.StandardService startInternal INFO: Starting
    service Tomcat Jul 05, 2017 4:20:23 PM
    org.apache.catalina.core.StandardEngine startInternal INFO: Starting
    Servlet Engine: Apache Tomcat/7.0.47 Jul 05, 2017 4:20:27 PM
    com.sun.jersey.api.core.PackagesResourceConfig init INFO: Scanning for
    root resource and provider classes in the packages:<br>
    org.arpit.java2blog.controller Jul 05, 2017 4:20:28 PM
    com.sun.jersey.api.core.ScanningResourceConfig logClasses INFO: Root
    resource classes found:   class
    org.arpit.java2blog.controller.FileUploadController   class
    org.arpit.java2blog.controller.CountryController   class
    org.arpit.java2blog.controller.KasusController Jul 05, 2017 4:20:28 PM
    com.sun.jersey.api.core.ScanningResourceConfig init INFO: No provider
    classes found. Jul 05, 2017 4:20:28 PM
    com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
    INFO: Initiating Jersey application, version 'Jersey: 1.19.3
    10/24/2016 03:43 PM' Jul 05, 2017 4:20:29 PM
    com.sun.jersey.spi.inject.Errors processErrorMessages SEVERE: The
    following errors and warnings have been detected with resource and/or
    provider classes:   SEVERE: Missing dependency for method public
    javax.ws.rs.core.Response
    org.arpit.java2blog.controller.FileUploadController.uploadFile(java.io.InputStream,org.glassfish.jersey.media.multipart.FormDataContentDisposition)
    at parameter at index 0   SEVERE: Missing dependency for method public
    javax.ws.rs.core.Response
    org.arpit.java2blog.controller.FileUploadController.uploadFile(java.io.InputStream,org.glassfish.jersey.media.multipart.FormDataContentDisposition)
    at parameter at index 1   SEVERE: Method, public
    javax.ws.rs.core.Response
    org.arpit.java2blog.controller.FileUploadController.uploadFile(java.io.InputStream,org.glassfish.jersey.media.multipart.FormDataContentDisposition),
    annotated with POST of resource, class
    org.arpit.java2blog.controller.FileUploadController, is not recognized
    as valid resource method. Jul 05, 2017 4:20:29 PM
    org.apache.catalina.core.ApplicationContext log SEVERE:
    StandardWrapper.Throwable
    com.sun.jersey.spi.inject.Errors$ErrorMessagesException   at
    com.sun.jersey.spi.inject.Errors.processErrorMessages(Errors.java:170)
      at com.sun.jersey.spi.inject.Errors.postProcess(Errors.java:136)    at
    com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:199)
      at
    com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:795)
      at
    com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:790)
      at
    com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:509)
      at
    com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:339)
      at
    com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:605)
      at
    com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:207)
      at
    com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:394)
      at
    com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:577)
      at javax.servlet.GenericServlet.init(GenericServlet.java:160)   at
    org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)
      at
    org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193)
      at
    org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088)
      at
    org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5176)
      at
    org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5460)
      at
    org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      at
    org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
      at
    org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)     at
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:748)</p>
    
    <p>Jul 05, 2017 4:20:29 PM org.apache.catalina.core.StandardContext
    loadOnStartup SEVERE: Servlet /JSONExampleJAXB threw load() exception
    com.sun.jersey.spi.inject.Errors$ErrorMessagesException   at
    com.sun.jersey.spi.inject.Errors.processErrorMessages(Errors.java:170)
      at com.sun.jersey.spi.inject.Errors.postProcess(Errors.java:136)    at
    com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:199)
      at
    com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:795)
      at
    com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:790)
      at
    com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:509)
      at
    com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:339)
      at
    com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:605)
      at
    com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:207)
      at
    com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:394)
      at
    com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:577)
      at javax.servlet.GenericServlet.init(GenericServlet.java:160)   at
    org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)
      at
    org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193)
      at
    org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088)
      at
    org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5176)
      at
    org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5460)
      at
    org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      at
    org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
      at
    org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)     at
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:748)</p>
  </blockquote>
  
  <p>my pom.xml</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;com.project&lt;/groupId&gt;
      &lt;artifactId&gt;JSONExampleJAXB&lt;/artifactId&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;JSONExampleJAXB Maven Webapp&lt;/name&gt;
      &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  
      &lt;properties&gt;
          &lt;jersey.version&gt;1.19.3&lt;/jersey.version&gt;
          &lt;java-version&gt;1.8&lt;/java-version&gt;
          &lt;org.springframework-version&gt;4.3.8.RELEASE&lt;/org.springframework-version&gt;
          &lt;jackson.version&gt;2.7.5&lt;/jackson.version&gt;
          &lt;jaxb-api.version&gt;2.2.11&lt;/jaxb-api.version&gt;
          &lt;hibernate.version&gt;4.3.11.Final&lt;/hibernate.version&gt;
          &lt;slf4j.version&gt;1.7.21&lt;/slf4j.version&gt;           
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;!-- Local Libraries --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.sap.hana&lt;/groupId&gt;
              &lt;artifactId&gt;ng&lt;/artifactId&gt;
              &lt;version&gt;1.0&lt;/version&gt;
              &lt;scope&gt;system&lt;/scope&gt;
              &lt;systemPath&gt;${basedir}/src/main/webapp/WEB-INF/lib/ngdbc-1.0.jar&lt;/systemPath&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;version&gt;3.8.1&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;javax.ws.rs&lt;/groupId&gt;
              &lt;artifactId&gt;javax.ws.rs-api&lt;/artifactId&gt;
              &lt;version&gt;2.1-m05&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;!-- Dependency untuk mysql --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;version&gt;5.1.9&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- JSON Dependency --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;
              &lt;version&gt;2.2.2&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- Jersey --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.jersey.contribs&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-multipart&lt;/artifactId&gt;
              &lt;version&gt;${jersey.version}&lt;/version&gt;
          &lt;/dependency&gt;       
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-servlet&lt;/artifactId&gt;
              &lt;version&gt;${jersey.version}&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-core&lt;/artifactId&gt;
              &lt;version&gt;${jersey.version}&lt;/version&gt;
          &lt;/dependency&gt;   
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-server&lt;/artifactId&gt;
              &lt;version&gt;${jersey.version}&lt;/version&gt;
          &lt;/dependency&gt;   
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-json&lt;/artifactId&gt;
              &lt;version&gt;${jersey.version}&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- Mimepull untuk prerequisites upload file --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.jvnet.mimepull&lt;/groupId&gt;
              &lt;artifactId&gt;mimepull&lt;/artifactId&gt;
              &lt;version&gt;1.9.4&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!--  --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.jboss.resteasy&lt;/groupId&gt;
              &lt;artifactId&gt;resteasy-jaxrs&lt;/artifactId&gt;
              &lt;version&gt;2.2.1.GA&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.jboss.resteasy&lt;/groupId&gt;
              &lt;artifactId&gt;resteasy-jaxb-provider&lt;/artifactId&gt;
              &lt;version&gt;2.2.0.GA&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.jboss.resteasy&lt;/groupId&gt;
              &lt;artifactId&gt;resteasy-jettison-provider&lt;/artifactId&gt;
              &lt;version&gt;2.2.0.GA&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- https://mvnrepository.com/artifact/javax.persistence/persistence-api --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.persistence&lt;/groupId&gt;
              &lt;artifactId&gt;persistence-api&lt;/artifactId&gt;
              &lt;version&gt;1.0&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jersey.core&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-server&lt;/artifactId&gt;
              &lt;version&gt;2.10&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-media-multipart&lt;/artifactId&gt;
              &lt;version&gt;2.10&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jersey.containers&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-container-jdk-http&lt;/artifactId&gt;
              &lt;version&gt;2.10&lt;/version&gt;
          &lt;/dependency&gt;
  
      &lt;/dependencies&gt;
      &lt;build&gt;
          &lt;finalName&gt;JSONExampleJAXB&lt;/finalName&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;version&gt;3.3&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.7&lt;/source&gt;
                      &lt;target&gt;1.7&lt;/target&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
  
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.tomcat.maven&lt;/groupId&gt;
                  &lt;artifactId&gt;tomcat7-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.2&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;port&gt;8087&lt;/port&gt;
                      &lt;path&gt;/JSONExampleJAXB&lt;/path&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
  
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>my web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns="http://java.sun.com/xml/ns/javaee"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
      version="3.0"&gt;
      &lt;display-name&gt;Archetype Created Web Application&lt;/display-name&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;jersey-serlvet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;com.sun.jersey.spi.container.servlet.ServletContainer&lt;/servlet-class&gt;
  
          &lt;init-param&gt;
              &lt;param-name&gt;com.sun.jersey.config.property.packages&lt;/param-name&gt;
              &lt;param-value&gt;org.arpit.java2blog.controller&lt;/param-value&gt;
          &lt;/init-param&gt;
  
          &lt;init-param&gt;
              &lt;param-name&gt;com.sun.jersey.api.json.POJOMappingFeature&lt;/param-name&gt;
              &lt;param-value&gt;true&lt;/param-value&gt;
          &lt;/init-param&gt;
  
          &lt;init-param&gt;
              &lt;param-name&gt;com.sun.jersey.spi.container.ContainerResponseFilters&lt;/param-name&gt;
              &lt;param-value&gt;org.arpit.java2blog.config.CORSFilter&lt;/param-value&gt;
          &lt;/init-param&gt;
  
          &lt;init-param&gt;  
              &lt;param-name&gt;org.arpit.java2blog.controller.FileUploadController&lt;/param-name&gt;  
              &lt;param-value&gt;org.glassfish.jersey.filter.LoggingFilter;  
               org.glassfish.jersey.media.multipart.MultiPartFeature&lt;/param-value&gt;  
          &lt;/init-param&gt;       
  
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;jersey-serlvet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;  
  </code></pre>
  
  <p>FileUploadController.java</p>
  
  <pre><code>package org.arpit.java2blog.controller;
  
  import java.io.File;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.io.InputStream;
  
  import javax.ws.rs.Consumes;
  import javax.ws.rs.POST;
  import javax.ws.rs.Path;
  import javax.ws.rs.core.MediaType;
  import javax.ws.rs.core.Response;
  
  import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
  import org.glassfish.jersey.media.multipart.FormDataParam;
  
  @Path("/files") 
  public class FileUploadController {
  
      @POST  
      @Path("/upload")  
      @Consumes(MediaType.MULTIPART_FORM_DATA)  
      public Response uploadFile(  
              @FormDataParam("file") InputStream uploadedInputStream,  
              @FormDataParam("file") FormDataContentDisposition fileDetail) {  
              String fileLocation = "d://" + fileDetail.getFileName();  
                      //saving file  
              try {  
                  FileOutputStream out = new FileOutputStream(new File(fileLocation));  
                  int read = 0;  
                  byte[] bytes = new byte[1024];  
                  out = new FileOutputStream(new File(fileLocation));  
                  while ((read = uploadedInputStream.read(bytes)) != -1) {  
                      out.write(bytes, 0, read);  
                  }  
                  out.flush();  
                  out.close();  
              } catch (IOException e) {e.printStackTrace();}  
              String output = "File successfully uploaded to : " + fileLocation;  
              return Response.status(200).entity(output).build();  
          }   
  
  }
  </code></pre>