java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.startAsync
오류 기록 2020. 6. 22. 08:41- @참고2 : https://www.jetbrains.com/help/idea/work-with-maven-dependencies.html
에러 내역
java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.getAsyncContext()Ljavax/servlet/AsyncContext; at org.springframework.test.web.servlet.TestDispatcherServlet.service(TestDispatcherServlet.java:73) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at org.springframework.mock.web.MockFilterChain$ServletFilterProxy.doFilter(MockFilterChain.java:160) at org.springframework.mock.web.MockFilterChain.doFilter(MockFilterChain.java:127) at org.springframework.test.web.servlet.MockMvc.perform(MockMvc.java:151) at com.wizvera.pinsign.admin.web.controller.LoginControllerTest.loginTest(LoginControllerTest.java:70) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
해결방법
servlet version이 3.0 이상이어야 javax.servlet.http.HttpServletRequest.getAsyncContext() 해당 메소드가 존재하는데 servlet 버전이 낮아 해당 메소드가 존재하지 않아서 나는 에러이다. 내 경우에는 pom.xml에서 servlet version을 3.1로 맞추었지만 cors-filter에서 transitively하게 v2.5를 가져와서 해당 에러가 났다. 따라서 전이적으로 낮은 servlet 버전을 가져온 cors-filter의 버전을 1.3.2에서 2.5로 올려줬더니 getAsyncContext()를 찾는다.
또는
exclusion을 통해 버전을 잘못가져온 해당 라이브러리를 제외해주니 해결된다.
<dependency>
<groupId>com.thetransactioncompany</groupId>
<artifactId>cors-filter</artifactId>
<version>1.3.2</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
'오류 기록' 카테고리의 다른 글
[Spring MVC] java.lang.NoClassDefFoundError: javax/servlet/SessionCookieConfig (0) | 2020.06.22 |
---|---|
[Eclipse Spring MVC with Maven] Cannot change version of project facet Dynamic Web Module to 2.5. (0) | 2020.06.22 |
[Eclipse, Maven] Unable to load annotation processor factory jar for project (0) | 2020.01.28 |
[Postman] https request fail 오류 (0) | 2019.11.15 |
이클립스(Eclipse) 실행 시 아무 반응이 없는 오류 해결 (0) | 2019.06.20 |