[Solved] The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path in Eclipse

1. Problem

If you are facing this error after importing an existing maven project into your eclipse IDE, then it means that http-servlet is not available in the project’s classpath and you must include it.

The error looks like this.

Java Build Path Error
Java Build Path Error

2. Solution

To include http-servlet into your classpath, you have two options.

1. Add Target Server Runtime

In this solution, you can add desired server runtime into your application as a project facet. As runtime servers have already servlet runtime dependencies, they get included in your project and hence the error is gone.

Update Project Runtime

2. Add Maven Dependency

Another option is to include the latest version of javax.servlet-api dependency from Maven repository. This will also fix the error.

Do not forget to run mvn update command after including the dependencies.


If you are using Jakarta servlet API, then you should be using the latest version of jakarta.servlet-api.


Happy Learning !!


Notify of
Most Voted
Newest Oldest
Inline Feedbacks
View all comments

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.

Our Blogs

REST API Tutorial

Dark Mode

Dark Mode