Acknowledgement URL: http://stackoverflow.com/questions/25940571/ java-lang-nosuchmethoderror-javaxservlet-http-httpservletrequest-isasyncstarted/
--------------------------------------------------------------------------------------------------------------- ------------------------
Scenario: This problem occurs when doing a SPRINGMCV test--Executing the simple method
PackageCom.springapp.mvc;ImportOrg.junit.Before;Importorg.junit.Test;ImportOrg.junit.runner.RunWith;Importorg.springframework.beans.factory.annotation.Autowired;Importorg.springframework.test.context.ContextConfiguration;ImportOrg.springframework.test.context.junit4.SpringJUnit4ClassRunner;Importorg.springframework.test.context.web.WebAppConfiguration;ImportORG.SPRINGFRAMEWORK.TEST.WEB.SERVLET.MOCKMVC;ImportOrg.springframework.web.context.WebApplicationContext;Import StaticOrg.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;Import StaticOrg.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;Import StaticOrg.springframework.test.web.servlet.result.MockMvcResultHandlers.print;Import StaticOrg.springframework.test.web.servlet.result.MockMvcResultMatchers.status;Import StaticOrg.springframework.test.web.servlet.result.MockMvcResultMatchers.view;Import StaticOrg.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup; @RunWith ( Springjunit4classrunner.class) @WebAppConfiguration @contextconfiguration ("File:src/main/webapp/web-inf/mvc-dispatcher-servlet.xml") Public classapptests {PrivateMockmvc Mockmvc; @SuppressWarnings ("Springjavaautowiringinspection") @AutowiredprotectedWebapplicationcontext WAC; @Before Public voidSetup () { This. Mockmvc = Webappcontextsetup ( This. WAC). build (); } @Test Public voidSimple ()throwsException {mockmvc.perform (post ("/mytest") . Andexpect (View (). Name ("Hello") . Anddo (print ()). Andexpect (Status (). IsOk ()); } }
The Netizen on this page also encounters the author same question, the Netizen Sam Brannen answer solves this question, the following post:
The content in the blue box is the reason for this problem and the workaround--the original version of the Org.springframework.mock.web package in Spring 4.0 requires a minimum of 3.0 Servlet-api
Resolution process:
1. Download version 3.0 of Servlet-api: http://download.csdn.net/download/wangdongj2ee/4260894
2. Follow the workaround in my blog http://www.cnblogs.com/wql025/p/4996484.html to move the downloaded jar to MAVEN's local repository.
The dependency code in Pom.xml is as follows:
<Dependency> <groupId>Javax.servlet</groupId> <Artifactid>Servlet-api</Artifactid> <version>3.0</version> </Dependency>
PostScript: The vast crowd, thanks to netizens in the network to share the wisdom of the source. Thank!
Java.lang.NoSuchMethodError:javaxservlet.http.HttpServletRequest.isAsyncStarted () Z