How to resolve the error - The superclass "javax.servlet.http.Httpservlet" was not found on the Java Build Path

Asked

Viewed 20,505 times

14

I’m using Eclipse Mars.1 for web development, I received this error when including a file JSP, The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path.

I also have Tomcat 8 running on PC.

  • Much simpler to just add Java EE5 Libraries to the build path

3 answers

18


As with the database, the Eclipse does not recognise the service of Apache Tomcat just because it is present in the system, a plugin is required for the Eclipse.

  • In Eclipse go to Window > Preferences > Server > Runtime Environments > Add > Apache Tomcat 8 > and set the directory that Tomcat was installed in my case C:\Program Files\Apache Software Foundation\Tomcat 8.0 ex:

Exemplo

  • Now select your project and right-click > Properties > Project Facets > Runtimes > select the Apache Tomcat 8, apply and a OK ex:

Exemplo

The error must have disappeared, trying to fix the problem, before all this installed on Eclipse a plugin for Tomcat and software Jboss Apache Tomcat Integration, but I don’t know how far these are needed.

9

The solution I found was a little different, and I’ll leave it here because just adding the server and changing Project Facets didn’t help me:

  1. In the archive pom.xml, in the field for dependencies, add:
<dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>javax.servlet-api</artifactId>
  <version>3.1.0</version>
  <scope>provided</scope>
</dependency>
  1. The change must be recognized immediately; otherwise, right-click on your project, option Maven --> Update Project (or just Alt+F5).
  • This is the solution if the project uses Maven and Eclipse has installed the M2E plugin (Maven 2 Eclipse). The version (3.1.0) is correct for Tomcat 8 as per documentation. Anyone using a different version of the server needs to check the correct version of the API.

1

Good evening, everyone

the ai solution to add the dependency on Maven solves as well. Just to help, it can be solved in the first way suggested by adding Target Runtime to Project Facets. It turns out that after doing this, you also need to configure the project to use the server libraries in question. For this, go to the Build Path settings, in the "Libraries" tab press the "Add Library" button, select "Server Runtime" and then the Server you used, in my case "Tomcat 7.0" Then just apply and that’s it.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.