title: Tomcat Not invoking Controller api's
body: <p>I am new to spring and I am trying maven spring web application. 
  when I try to call any API from controller on postman, I am getting <code>http status 404 not found</code>. But <code>index.jsp</code> is running on the home page of the webapp. </p>
  
  <p>SpringConfig.xml:</p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:context="http://www.springframework.org/schema/context"
     xmlns:mongo="http://www.springframework.org/schema/data/mongo"
     xsi:schemaLocation="http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/data/mongo
        http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"&gt;
  
  
  &lt;mongo:mongo id="mongo" host="127.0.0.1" port="27017" /&gt;
  &lt;mongo:db-factory dbname="employee" /&gt;
  &lt;mongo:repositories base-package="com.mongofunction.base.Repository"/&gt;
  
  &lt;context:component-scan base-package="com.mongofunction.base"/&gt;
  
  
  &lt;bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"&gt;
      &lt;constructor-arg name="mongoDbFactory" ref="mongo" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p></p>
  
  <p>web.xml:</p>
  
  <pre><code>    &lt;!DOCTYPE web-app PUBLIC
   "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
   "http://java.sun.com/dtd/web-app_2_3.dtd" &gt;
  
  &lt;web-app&gt;
    &lt;display-name&gt;Archetype Created Web Application&lt;/display-name&gt;
    &lt;servlet&gt;
      &lt;servlet-name&gt;spring controller&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;spring controller&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/.*&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>package com.mongofunction.base.Controller;
  
  import com.mongofunction.base.ApplicationRuntimeException.ApplicationRuntimeException;
  import com.mongofunction.base.DTO.EmployeeDTO;
  import com.mongofunction.base.DTO.ResponseDTO;
  import com.mongofunction.base.Service.EmployeeService;
  import com.mongofunction.base.model.Employee;
  import org.json.simple.JSONObject;
  import org.springframework.beans.BeanUtils;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.http.HttpStatus;
  import org.springframework.web.bind.annotation.*;
  
  import java.util.List;
  
  @RestController
  @RequestMapping(value = "/employee")
  public class EmployeeController {
      @Autowired
      EmployeeService employeeService;
  
      @RequestMapping(value = "",method = RequestMethod.PUT)
      public ResponseDTO add(EmployeeDTO employeeDTO)
      {
          ResponseDTO responseDTO=new ResponseDTO();
          try {
          Employee employee = new Employee();
          BeanUtils.copyProperties(employeeDTO, employee);
          if (employee.checkNull() != null)
              throw new ApplicationRuntimeException(employee.checkNull() + " Not Found");
          employee=employeeService.add(employee);
          if(employee==null)
              throw new ApplicationRuntimeException("Error Adding to Database");
          responseDTO.setValue("Added Successfully",HttpStatus.CREATED);
      }catch (ApplicationRuntimeException e)
      {
         responseDTO.setValue(e.getMessage(), HttpStatus.BAD_GATEWAY);
      }
          return responseDTO;
      }
  
      @RequestMapping(value = "", method = RequestMethod.GET)
      public ResponseDTO getAllEmployee()
      {
          ResponseDTO responseDTO = new ResponseDTO();
          List&lt;Employee&gt; employeeList;
          try {
              employeeList=employeeService.getAll();
              if(employeeList==null||employeeList.isEmpty())
                  throw new ApplicationRuntimeException("NO Records Found");
              JSONObject jsonObject = new JSONObject();
              jsonObject.put("EmployeeList", employeeService.getAll());
              responseDTO.setData(jsonObject);
              responseDTO.setValue("Records Found", HttpStatus.ACCEPTED);
          } catch (Exception e) {
              responseDTO.setValue(e.getMessage(), HttpStatus.BAD_REQUEST);
          }
          return responseDTO;
      }
      @RequestMapping(value = "/{employeeId}", method = RequestMethod.GET)
      public ResponseDTO getEmployee(@PathVariable String employeeId) {
          System.out.println(employeeId);
          ResponseDTO responseDTO = new ResponseDTO();
          JSONObject jsonObject = new JSONObject();
          try {
  
              Employee employee = employeeService.get(employeeId);
              if(employee==null)
                  throw new ApplicationRuntimeException("Record Not Found");
              responseDTO.setValue("Record Found", HttpStatus.OK);
              jsonObject.put("data", employee);
              responseDTO.setData(jsonObject);
          } catch (Exception e) {
              responseDTO.setValue(e.getMessage(), HttpStatus.BAD_REQUEST);
  
          }
          return responseDTO;
      }
      @RequestMapping(value = "", method = RequestMethod.PUT)
      public ResponseDTO updateEmployee(@RequestBody EmployeeDTO employeeDTO) {
          ResponseDTO responseDTO = new ResponseDTO();
  
          try {
  
  
              Employee employee = new Employee();
              BeanUtils.copyProperties(employeeDTO, employee);
              if (employee.checkNull() != null)
                  throw new ApplicationRuntimeException(employee.checkNull() + " Not Found");
              employee=employeeService.update(employee);
              if(employee==null)
                  throw new ApplicationRuntimeException("Not Updated to the database");
  
              responseDTO.setValue("Updated Successfully", HttpStatus.ACCEPTED);
  
          } catch (Exception e) {
              responseDTO.setValue(e.getMessage(), HttpStatus.BAD_GATEWAY);
          }
          return responseDTO;
      }
      @RequestMapping(value = "/{employeeId}", method = RequestMethod.DELETE)
      public ResponseDTO deleteEmployee(@PathVariable String employeeId) {
          ResponseDTO responseDTO = new ResponseDTO();
          try {
              employeeService.delete(employeeId);
              responseDTO.setValue("Deleted Successfully", HttpStatus.ACCEPTED);
  
          } catch (Exception e) {
              responseDTO.setValue(e.getMessage(), HttpStatus.BAD_REQUEST);
          }
          return responseDTO;
  
      }
  
  
  }
  </code></pre>
  
  <p>When I tried to call this URL through postman -> <code>localhost8080/MongoMaven/employee</code>, I get <code>http status 404 not found</code> error. 
  (<code>MongoMaven</code> is the webapp folder name)</p>
  
  <p><em>I know spring boot is better to use but still i was asked to do this in spring data web app .</em> </p>