title: java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.isAsyncStarted() while using Mockito with Junit
body: <p>I am trying to get my feet wet with TDD. I am trying to write unit test cases for controllers using Mockito in conjunction with MockMvc and Junit.</p>
  
  <p>But I am getting a runtime error thereby failing my test. At first I was facing problem in initializing the MockMvc instance in the setup due to failure in finding the <code>javax.servlet.SessionCookieConfig</code>.</p>
  
  <p>This I resolved by downloading the <code>javax.servlet</code> api and configuring it into the build path of the project but then I am facing the</p>
  
  <pre><code>java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.isAsyncStarted()
  </code></pre>
  
  <p>while using <code>perform()</code> on the MockMvc instance.</p>
  
  <p>Can anyone tell me what to do with this kind of dependencies as I think it is occurring due to the incompatible server servlet-api and javax.servlet api.</p>
  
  <p>EDIT : I am posting the code I am using using for unit testing but I don't think it would be any help but just in case : </p>
  
  <pre><code>@RunWith(MockitoJUnitRunner.class)
  public class MyControllerTest {
  
      @InjectMocks
      private MyController myController = new MyController();
  
      @Mock
      private MyService myService = new MyServiceImpl();
  
      private MockMvc mockMvc;
  
      @Before
      public void setUp(){
          this.mockMvc = MockMvcBuilders.standaloneSetup(myController).build();
      }
  
      @Test
      public void testList() throws Exception{
          A a = new A();
          a = createMockClassA();
  
          Mockito.when(myService.getServiceForA(Mockito.anyMapOf(String.class, String.class))).thenReturn(a);
  
          MvcResult result = this.mockMvc.perform(get("/somePath/")).param("someExpectedParam","value").andReturn(); 
  
          System.out.println(result.getResponse().getContentAsString());
  
      }
  
  
  
      private static A createMockClassA(){
          A a = new A();
          a.setId(i);
          a.setTitle("mock-" + i);
          return a;
      }
  }
  </code></pre>