title: HTTP POST Returns 404 Not Found
body: <p>I have a Spring Web MVC application with MongoDB, which stores files in Azure Blob Storage.
  When I send a POST request with a zip file to be stored in Postman I receive Status Code 404 Not found. My logs look like this:</p>
  <pre><code>2022-05-21 06:18:05.421 DEBUG 11816 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Exiting from &quot;ERROR&quot; dispatch, status 404
  2022-05-21 06:18:18.595 DEBUG 11816 --- [nio-8080-exec-3] o.s.web.servlet.DispatcherServlet        : POST &quot;/api/upload&quot;, parameters={multipart}
  2022-05-21 06:18:18.604 DEBUG 11816 --- [nio-8080-exec-3] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped to ResourceHttpRequestHandler [classpath [META-INF/resources/], classpath [resources/], classpath [static/], classpath [public/], ServletContext [/]]
  2022-05-21 06:18:18.608 DEBUG 11816 --- [nio-8080-exec-3] o.s.w.s.r.ResourceHttpRequestHandler     : Resource not found
  2022-05-21 06:18:18.608 DEBUG 11816 --- [nio-8080-exec-3] o.s.web.servlet.DispatcherServlet        : Completed 404 NOT_FOUND
  2022-05-21 06:18:18.609 DEBUG 11816 --- [nio-8080-exec-3] o.s.web.servlet.DispatcherServlet        : &quot;ERROR&quot; dispatch for POST &quot;/error&quot;, parameters={multipart}
  2022-05-21 06:18:18.609 DEBUG 11816 --- [nio-8080-exec-3] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#error(HttpServletRequest)
  2022-05-21 06:18:18.610 DEBUG 11816 --- [nio-8080-exec-3] o.s.w.s.m.m.a.HttpEntityMethodProcessor  : Using 'application/json', given [*/*] and supported [application/json, application/*+json, application/json, application/*+json, application/xml;charset=UTF-8, text/xml;charset=UTF-8, application/*+xml;charset=UTF-8, application/xml;charset=UTF-8, text/xml;charset=UTF-8, application/*+xml;charset=UTF-8]
  2022-05-21 06:18:18.610 DEBUG 11816 --- [nio-8080-exec-3] o.s.w.s.m.m.a.HttpEntityMethodProcessor  : Writing [{timestamp=Sat May 21 06:18:18 CEST 2022, status=404, error=Not Found, message=No message available, (truncated)...]
  2022-05-21 06:18:18.611 DEBUG 11816 --- [nio-8080-exec-3] o.s.web.servlet.DispatcherServlet        : Exiting from &quot;ERROR&quot; dispatch, status 404
  </code></pre>
  <p>I have the following classes:<br />
  <strong>CalibrationController.java</strong></p>
  <pre><code>@Controller
  public class CalibrationController {
  
      private final CalibrationService calService;
      private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(CalibrationController.class);
  
      @Autowired
      public CalibrationController (CalibrationService calService) {
          this.calService = calService;
      }
    
      @PostMapping(path = &quot;/upload&quot;, consumes = {MediaType.MULTIPART_FORM_DATA_VALUE})
        @ResponseBody
          public ResponseEntity&lt;String&gt; newBundle(@RequestParam(&quot;file&quot;) MultipartFile file) {
              log.info(&quot;Received a file to upload&quot;);
             Calibration created = calService.uploadBundle(file);           
             return ResponseEntity.status(HttpStatus.CREATED).body(&quot;Bundle was saved successfully with URI: &quot; + created.getUrl());
             
      }
      
  }
  </code></pre>
  <p><strong>CalibrationInitializer.java</strong></p>
  <pre><code>public class CalibrationInitializer implements WebApplicationInitializer{
  
     @Override
     public void onStartup(ServletContext ServletContext){
         // Load Spring web application configuration
        AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
        context.register(CalibrationServletConfig.class);
  
        // Create and register the DispatcherServlet
        DispatcherServlet servlet = new DispatcherServlet(context);
        ServletRegistration.Dynamic registration = ServletContext.addServlet(&quot;api&quot;, servlet);
        registration.setLoadOnStartup(1);
        registration.addMapping(&quot;/api/*&quot;);
     }
  }
  </code></pre>
  <p><strong>CalibrationServletConfig.java</strong></p>
  <pre><code>@Configuration
  @EnableWebMvc
  @ComponentScan(basePackages = {&quot;com.example.prototype_mvc.databaseStorage.controller&quot;})
  public class CalibrationServletConfig {
  
          
  }
  </code></pre>
  <p>I've tried to create the implementation for Dispatcher Servlet as a possible solution for this error because I was getting it also without the <strong>CalibrationInitialize.java</strong> and <strong>CalibrationConfig.java</strong> classes. So shouldn't my application run also without initialization and registration of Dispatcher Servlet, if I am having annotated controller? Shouldn't the annotations in the <strong>Controller.java</strong> class be recognized?<br />
  I really don't know what I am doing wrong. Any help would be useful!</p>