MAVEN builds a Web project, cannot is cast to Javax.servlet.Servlet

Source: Internet
Author: User
Tags tld

The following exception was found when debugging Spring MVC:

Java.lang.ClassCastException:org.springframework.web.servlet.DispatcherServlet cannot is cast to Javax.servlet.Servlet

The problem is with Servlet-api.jar, when Tomcat deploys the SPRINGMVC project without this package, and when you build a project with Maven, you don't recognize classes like httpservletrequest if you don't reference that dependency

The workaround is to include the attribute scope when Maven references a servlet dependency <scope>provided</scope>


If you do not add an attribute range <scope>provided</scope> when referencing javax.servlet.jsp dependencies, you will also throw the following exception:


Org.apache.jasper.JasperException:Unable to read TLD "Meta-inf/c.tld" from JAR file "file:/e:/chenzehe/mvnrepo/javax/ Servlet/jstl/1.2/jstl-1.2.jar ": org.apache.jasper.JasperException:Failed to load or instantiate Taglibraryvalidator Class:org.apache.taglibs.standard.tlv.JstlCoreTLV


MAVEN builds a Web project, cannot is cast to Javax.servlet.Servlet

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.