title: Spring MVC file upload - Unable to process parts as no multi-part configuration has been provided
body: <p>So I'm a newbie to Spring and I'm trying to get file upload working for my project (I'm using Spring Tool Suite btw.) and when submitting a form all I'm getting is:</p>
  
  <blockquote>
    <p>HTTP Status 500 - Could not parse multipart servlet request; nested exception is java.lang.IllegalStateException: Unable to process parts as no multi-part configuration has been provided</p>
  </blockquote>
  
  <p>Stack trace from browser:</p>
  
  <pre>
  type Exception report
  
  message Could not parse multipart servlet request; nested exception is java.lang.IllegalStateException: Unable to process parts as no multi-part configuration has been provided
  
  description The server encountered an internal error that prevented it from fulfilling this request.
  
  exception
  
  org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.lang.IllegalStateException: Unable to process parts as no multi-part configuration has been provided
      org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.parseRequest(StandardMultipartHttpServletRequest.java:100)
      org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.(StandardMultipartHttpServletRequest.java:78)
      org.springframework.web.multipart.support.StandardServletMultipartResolver.resolveMultipart(StandardServletMultipartResolver.java:75)
      org.springframework.web.multipart.support.MultipartFilter.doFilterInternal(MultipartFilter.java:108)
      org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:106)
  root cause
  
  java.lang.IllegalStateException: Unable to process parts as no multi-part configuration has been provided
      org.apache.catalina.connector.Request.parseParts(Request.java:2676)
      org.apache.catalina.connector.Request.getParts(Request.java:2643)
      org.apache.catalina.connector.RequestFacade.getParts(RequestFacade.java:1083)
      org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.parseRequest(StandardMultipartHttpServletRequest.java:85)
      org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.(StandardMultipartHttpServletRequest.java:78)
      org.springframework.web.multipart.support.StandardServletMultipartResolver.resolveMultipart(StandardServletMultipartResolver.java:75)
      org.springframework.web.multipart.support.MultipartFilter.doFilterInternal(MultipartFilter.java:108)
      org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:106)
  
  note The full stack trace of the root cause is available in the Apache Tomcat/8.0.27 logs.
  </pre>
  
  <p>This is the form tag in jsp:</p>
  
  <pre><code>&lt;form:form class="form-horizontal" role="form" method="post"
              action="newArtist.html" modelAttribute="artist" enctype="multipart/form-data"&gt;
  </code></pre>
  
  <p>Input part:</p>
  
  <pre><code>&lt;div class="form-group"&gt;
      &lt;div class="col-lg-3"&gt;
          &lt;label for="photo"&gt;Artist photo:&lt;/label&gt;
          &lt;form:input type="file" id="photo" path="photo"&gt;&lt;/form:input&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Photo is stored in this field in Artist object:</p>
  
  <pre><code>@Lob
  private byte[] photo;
  </code></pre>
  
  <p>Controller mapping methods:</p>
  
  <pre><code>@RequestMapping(value = "/newArtist", method = RequestMethod.GET)
  public String showAddArtistForm(Model model)
  {
      model.addAttribute("artist", new Artist());
      return "newArtist";
  }
  
  @RequestMapping(value = "/newArtist", method = RequestMethod.POST)
  public String addArtist(@ModelAttribute("artist") @Valid Artist artist, BindingResult result,
          @RequestParam("photo") MultipartFile photo) throws IOException
  {   
      if (result.hasErrors())
          return "newArtist";
  
      if(photo.getBytes() != null)
          artist.setPhoto(photo.getBytes());
  
      artistService.addArtist(artist);
  
      return "redirect:artists.html";
  }
  </code></pre>
  
  <p>Multipart resolver configuration in servlet-context.xml:</p>
  
  <pre><code>&lt;bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"&gt;
      &lt;property name="maxUploadSize" value="10000000"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>Filters in web.xml:</p>
  
  <pre><code>&lt;filter&gt;
      &lt;filter-name&gt;MultipartFilter&lt;/filter-name&gt;
      &lt;filter-class&gt;org.springframework.web.multipart.support.MultipartFilter&lt;/filter-class&gt;
  &lt;/filter&gt;
  &lt;filter&gt;
      &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
      &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt;
  &lt;/filter&gt;
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;MultipartFilter&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  </code></pre>
  
  <p>Dependencies:</p>
  
  <pre><code>&lt;!-- Apache Commons FileUpload --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;commons-fileupload&lt;/groupId&gt;
          &lt;artifactId&gt;commons-fileupload&lt;/artifactId&gt;
          &lt;version&gt;1.3.1&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Apache Commons IO --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;commons-io&lt;/groupId&gt;
          &lt;artifactId&gt;commons-io&lt;/artifactId&gt;
          &lt;version&gt;2.4&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>I also imported Tomcat's config file context.xml to META-INF/context.xml and edited Context tag like so:</p>
  
  <pre><code>&lt;Context allowCasualMultipartParsing="true"&gt;
  </code></pre>
  
  <p>Nothing seems to be working, any help will be greatly appreciated.</p>