Java.lang.NoSuchMethodError:javaxservlet.http.HttpServletRequest.isAsyncStarted () Z

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.