title: @Controller causing java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest
body: <p>Why do I get <code>java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest</code> when I add <code>@Controller</code> to <code>DummyController</code> class?</p>
  
  <p><strong>it.cspnet.firstspringmvc.controller.Main</strong></p>
  
  <pre><code>   public static void main(String args[]) {
          ApplicationContext ctx = new ClassPathXmlApplicationContext("jpaContext.xml");
          Servizi servizi = ctx.getBean(Servizi.class);
          Utente utente = new Utente();
          utente.setUserName("test");
          utente.setPassword("test");
          Utente utenteInDb = servizi.login(utente);
  
          for (Ordine ordine : utenteInDb.getOrdini()) {
              System.out.println("ordine: " + ordine);
          }
      }
  </code></pre>
  
  <p><strong>it.cspnet.firstspringmvc.controller.DummyController</strong></p>
  
  <pre><code>import org.springframework.stereotype.Controller;
  import org.springframework.ui.Model;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import javax.servlet.http.HttpServletRequest;
  
  @Controller
  public class DummyController {
  
      @RequestMapping(value = "/dummy", method = {RequestMethod.GET})
      public String get(Model model, HttpServletRequest request) {
          return "dummy";
      }
  }
  </code></pre>
  
  <p>When I remove the <code>@Controller</code> annotation from <strong>DummyController</strong> then main prints out the <code>example</code>'s fine but if I put it back in then it throws:</p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.NoClassDefFoundError:
    javax/servlet/http/HttpServletRequest     at
    java.lang.Class.getDeclaredMethods0(Native Method)</p>
  </blockquote>
  
  <p>I'm using this project:</p>
  
  <p><a href="https://github.com/ivansaracino/spring-mvc-jparepository-example.git" rel="nofollow">https://github.com/ivansaracino/spring-mvc-jparepository-example.git</a></p>
  
  <p>All I've done is add <strong>Main</strong> and <strong>DummyController</strong></p>