java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.isAsyncStarted() while using Mockito with Junit

前端 未结 6 700
清歌不尽
清歌不尽 2020-12-20 13:48

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.

But I am getting a

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-20 14:21

    This sounds very much like you have the wrong version of the servlet API in the class path.

    Check when isAsyncStarted was added to the API and make sure the one you reference in your classpath is at least that version or higher.

    In order to find the location where the 'wrong' class version is comming from you can use the

    -verbose:class
    

    Argument for java. It will list all the classes loaded and if I remember correctly whery they get loaded from. See http://docs.oracle.com/javase/7/docs/technotes/tools/windows/java.html for details.

提交回复
热议问题