Unable to process parts as no multi-part configuration has been provided

By Steve Claridge on 2017-06-21.

If you are creating a Java Servlet and you are getting the Unable to process parts as no multi-part configuration has been provided IllegalStateException error then you need to add the @MultipartConfig annotation to your class definition.

@MultipartConfig
public class ProductCsv extends HttpServlet
{
}

This error commonly comes up when trying to upload a file from an HTML form to a servlet, the form will look something like

<form style="margin-top: 40px" action="" enctype='multipart/form-data' method="POST">
  <input type="file" name="thefile">
  <input type="submit">
</form>

So basic rule is if you have a form with enctype='multipart/form-data' then annotate your HttpServlet class with @MultipartConfig