title: Could not parse multipart servlet request;.IllegalStateException: Unable to process parts as no multi-part configuration has been provided
body: <p>I'm unable to upload an image to the server. I've tried many solutions to related problems here but none working yet for me. Here are my files:</p>
  
  <p>SecurityApplicationInitializer:</p>
  
  <pre><code>        package com.App.config;
  
          import javax.servlet.ServletContext;
  
          import org.springframework.context.annotation.Configuration;
          import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer;
          import org.springframework.web.multipart.support.MultipartFilter;
  
          @Configuration
          public class AppSecurityApplicationInitializer extends AbstractSecurityWebApplicationInitializer {
  
              @Override
              protected void beforeSpringSecurityFilterChain(ServletContext servletContext) {
                  insertFilters(servletContext, new MultipartFilter());
              }
  
          }
  </code></pre>
  
  <p>WebMVCConfigurerAdapter:</p>
  
  <pre><code>    package com.App.config;
  
      import org.springframework.context.annotation.Bean;
      import org.springframework.context.annotation.ComponentScan;
      import org.springframework.context.annotation.ComponentScan.Filter;
      import org.springframework.context.annotation.Configuration;
      import org.springframework.context.annotation.FilterType;
      import org.springframework.jdbc.datasource.DriverManagerDataSource;
      import org.springframework.web.multipart.commons.CommonsMultipartResolver;
      import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
      import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
      import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
      import org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler;
      import org.springframework.web.servlet.view.InternalResourceViewResolver;
      import org.springframework.web.servlet.view.JstlView;
  
  
  
       //mvc:annotation-driven
      @Configuration
  
      @ComponentScan(basePackages ={ "com.App.controller", "com.App.mapper",
              "com.App.JDBC","com.App.model"      
      })//, excludeFilters = { 
      //@Filter(type = FilterType.ANNOTATION, value = Configuration.class) })
  
      public class AppConfig extends WebMvcConfigurerAdapter {
          int IMAGE_MAX_UPLOAD_SIZE = 8000;
  
          @Override
          public void addResourceHandlers(ResourceHandlerRegistry registry) {
              registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
          }
          @Override
          public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
  
          }
  
        @Bean
            public CommonsMultipartResolver multipartResolver() {
              CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
              multipartResolver.setMaxUploadSize(IMAGE_MAX_UPLOAD_SIZE);
              multipartResolver.setDefaultEncoding("utf-8");
              return multipartResolver;
            }
  
  
          @Bean
          public InternalResourceViewResolver viewResolver() {
              InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
              viewResolver.setViewClass(JstlView.class);
              viewResolver.setPrefix("/WEB-INF/views/jsp/");
              viewResolver.setSuffix(".jsp");
              return viewResolver;
          }
  
          /* @Bean 
           public UserRepositoryUserDetailsService getUserRepositoryUserDetailsService(UserRepository userRepository){
  
              UserRepositoryUserDetailsService bean = new UserRepositoryUserDetailsService(userRepository);
               return bean;
           }*/
          @Bean
          public DriverManagerDataSource getDatasource(){
              DriverManagerDataSource dataSource = new DriverManagerDataSource();
              dataSource.setDriverClassName("com.mysql.jdbc.Driver");
              dataSource.setPassword("....");
              dataSource.setUrl("....");
              dataSource.setUsername("root");
              return dataSource;
          }
          ...
      }
  </code></pre>
  
  <p>ServletInit:</p>
  
  <pre><code>    package com.App.config;
  
      import javax.servlet.Filter;
  
      import org.springframework.context.annotation.Configuration;
      import org.springframework.web.filter.HiddenHttpMethodFilter;
      import org.springframework.web.servlet.config.annotation.EnableWebMvc;
      import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
  
      @EnableWebMvc
      @Configuration
      public class AppWebInit extends
              AbstractAnnotationConfigDispatcherServletInitializer {
  
  
          @Override
          protected Class&lt;?&gt;[] getServletConfigClasses() {
              return new Class[] { AppConfig.class };
          }
  
          @Override
          protected String[] getServletMappings() {
              return new String[] { "/","/logout","/403", "/login" };
          }
  
          @Override
          protected Class&lt;?&gt;[] getRootConfigClasses() {
              return new Class[] { RootConfiguration.class };
          }
         @Override
          protected Filter[] getServletFilters() {
              return new Filter[] { new HiddenHttpMethodFilter() };
          }
      }
  </code></pre>
  
  <p>RootConfig:</p>
  
  <pre><code>    package com.App.config;
  
      import org.springframework.context.annotation.ComponentScan;
      import org.springframework.context.annotation.Configuration;
  
      /**
  
       *
       * @author E
       *
       */
      @Configuration
      @ComponentScan
      public class RootConfiguration {
  
      }
  </code></pre>
  
  <p>SecurityConfig:</p>
  
  <pre><code>    package com.App.config;
  
      import javax.sql.DataSource;
  
      import org.springframework.beans.factory.annotation.Autowired;
      import org.springframework.context.annotation.Configuration;
      import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
      import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
      import org.springframework.security.config.annotation.web.builders.HttpSecurity;
      import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
      import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
      import org.springframework.security.web.csrf.CsrfTokenRepository;
      import org.springframework.security.web.csrf.HttpSessionCsrfTokenRepository;
  
      @Configuration
      @EnableWebSecurity
      @EnableGlobalMethodSecurity(prePostEnabled=true)
      //@ComponentScan(basePackageClasses = UserRepositoryUserDetailsService.class)
      public class SecurityConfigure extends WebSecurityConfigurerAdapter{
  
          //@Autowired
          //private UserDetailsService userDetailsService;
  
  
           @Autowired
          private CsrfTokenRepository csrfTokenRepository() 
          { 
              HttpSessionCsrfTokenRepository repository = new HttpSessionCsrfTokenRepository(); 
              repository.setSessionAttributeName("_csrf");
              return repository; 
          }
           @Override
          protected void configure(HttpSecurity http) throws Exception {
  
          http
              .csrf()
                  .csrfTokenRepository(csrfTokenRepository())
                  .and()
              .authorizeRequests()
                  .antMatchers("/resources/**", "/signuPerson", "/login", "/", "/logout","viewBuyOrders").permitAll()
                  .anyRequest().authenticated()
                  .and()
              .formLogin()
                  .loginPage("/login")
                //.loginProcessingUrl("/processLogin")
                  //.failureUrl("login?error")
                  //
                  .permitAll()
                  .and()
              .logout()
                  .logoutUrl("/logout")
                 // .addLogoutHandler(new SecurityContextLogoutHandler())
                 // .logoutSuccessUrl("/403")
                   //
                  .permitAll();
  
          }
  
          @Autowired
          public void configureGlobal(DataSource dataSource , AuthenticationManagerBuilder auth) throws Exception {
          auth
              .jdbcAuthentication()
              .dataSource(dataSource)
              .usersByUsernameQuery("select login_username,  login_password, true from login where login_username = ?")
              .authoritiesByUsernameQuery("select login_username, 'ROLE_USER' from login where login_username = ? ");
  
          }
  
      }
  
      &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/xsd/maven-4.0.0.xsd"&gt;
        &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
        &lt;groupId&gt;App&lt;/groupId&gt;
        &lt;artifactId&gt;App&lt;/artifactId&gt;
        &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
        &lt;packaging&gt;war&lt;/packaging&gt;
        &lt;build&gt;
          &lt;sourceDirectory&gt;src&lt;/sourceDirectory&gt;
          &lt;plugins&gt;
            &lt;plugin&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.8&lt;/source&gt;
                &lt;target&gt;1.8&lt;/target&gt;
              &lt;/configuration&gt;
            &lt;/plugin&gt;
            &lt;plugin&gt;
            &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
              &lt;configuration&gt;
                &lt;warSourceDirectory&gt;WebContent&lt;/warSourceDirectory&gt;
                &lt;failOnMissingWebXml&gt;false&lt;/failOnMissingWebXml&gt;
              &lt;/configuration&gt;
            &lt;/plugin&gt;
          &lt;/plugins&gt;
        &lt;/build&gt;
         &lt;dependencies&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;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;jsp-api&lt;/artifactId&gt;
              &lt;version&gt;2.0&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&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.2&lt;/version&gt;
      &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
              &lt;version&gt;4.2.1.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
                  &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
              &lt;version&gt;4.2.1.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.batch&lt;/groupId&gt;
          &lt;artifactId&gt;spring-batch-core&lt;/artifactId&gt;
          &lt;version&gt;3.0.5.RELEASE&lt;/version&gt;
           &lt;/dependency&gt;
          &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.data&lt;/groupId&gt;
          &lt;artifactId&gt;spring-data-jpa&lt;/artifactId&gt;
          &lt;version&gt;1.9.2.RELEASE&lt;/version&gt;
         &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;
              &lt;version&gt;4.2.1.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
              &lt;version&gt;3.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;jstl&lt;/artifactId&gt;
          &lt;version&gt;1.2&lt;/version&gt;
      &lt;/dependency&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.36&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt; 
         &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
         &lt;artifactId&gt;spring-security-web&lt;/artifactId&gt;
         &lt;version&gt;4.0.3.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- 
      &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt;
                  &lt;version&gt;1.3.0.RELEASE&lt;/version&gt;
       &lt;/dependency&gt;--&gt;
               &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
          &lt;artifactId&gt;spring-security-config&lt;/artifactId&gt;
          &lt;version&gt;4.0.3.RELEASE&lt;/version&gt;
        &lt;/dependency&gt;
  
            &lt;/dependencies&gt;
  
      &lt;/project&gt;
  </code></pre>
  
  <p>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/xsd/maven-4.0.0.xsd"&gt;
        &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
        &lt;groupId&gt;App&lt;/groupId&gt;
        &lt;artifactId&gt;App&lt;/artifactId&gt;
        &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
        &lt;packaging&gt;war&lt;/packaging&gt;
        &lt;build&gt;
          &lt;sourceDirectory&gt;src&lt;/sourceDirectory&gt;
          &lt;plugins&gt;
            &lt;plugin&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.8&lt;/source&gt;
                &lt;target&gt;1.8&lt;/target&gt;
              &lt;/configuration&gt;
            &lt;/plugin&gt;
            &lt;plugin&gt;
            &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
              &lt;configuration&gt;
                &lt;warSourceDirectory&gt;WebContent&lt;/warSourceDirectory&gt;
                &lt;failOnMissingWebXml&gt;false&lt;/failOnMissingWebXml&gt;
              &lt;/configuration&gt;
            &lt;/plugin&gt;
          &lt;/plugins&gt;
        &lt;/build&gt;
         &lt;dependencies&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;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;jsp-api&lt;/artifactId&gt;
              &lt;version&gt;2.0&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&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.2&lt;/version&gt;
      &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
              &lt;version&gt;4.2.1.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
                  &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
              &lt;version&gt;4.2.1.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.batch&lt;/groupId&gt;
          &lt;artifactId&gt;spring-batch-core&lt;/artifactId&gt;
          &lt;version&gt;3.0.5.RELEASE&lt;/version&gt;
           &lt;/dependency&gt;
          &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.data&lt;/groupId&gt;
          &lt;artifactId&gt;spring-data-jpa&lt;/artifactId&gt;
          &lt;version&gt;1.9.2.RELEASE&lt;/version&gt;
         &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;
              &lt;version&gt;4.2.1.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
              &lt;version&gt;3.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;jstl&lt;/artifactId&gt;
          &lt;version&gt;1.2&lt;/version&gt;
      &lt;/dependency&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.36&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt; 
         &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
         &lt;artifactId&gt;spring-security-web&lt;/artifactId&gt;
         &lt;version&gt;4.0.3.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- 
      &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt;
                  &lt;version&gt;1.3.0.RELEASE&lt;/version&gt;
       &lt;/dependency&gt;--&gt;
               &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
          &lt;artifactId&gt;spring-security-config&lt;/artifactId&gt;
          &lt;version&gt;4.0.3.RELEASE&lt;/version&gt;
        &lt;/dependency&gt;
  
            &lt;/dependencies&gt;
  
      &lt;/project&gt;
  </code></pre>
  
  <p>Help will be appreciated.</p>