Friday, 23 June 2017

Error [solved] The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path ~ GNIITHELP

Problem : The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path.
Faced this error while using maven integration with eclipse. 
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> 
First found this error on the start of JSP page with one red mark over above piece of code.

Solution : Below, I have written three solution for this problem. I guess, one will work for you.

Method 1: Add Maven dependency(pom.xml)
Include servlet-api-3.1.jar in your dependencies.
 <dependency>  
  <groupId>javax.servlet</groupId>  
  <artifactId>javax.servlet-api</artifactId>  
  <version>3.1.0</version>  
  <scope>provided</scope>  
 </dependency>  

Method 2: Add a Runtimes
Properties > Project Facets > Runtimes > Check Server name > Apply > OK (As shown in Image)

Method 3: Select a Runtime to add to the classpath
Java Build Path > Libraries > Add Library > Server Runtime > Next (As shown in Image)
then select a Runtime(Apache Tomcat Server) > Finish > OK (As shown in Image)

    No comments:

    Post a Comment