9
respostas

Não Encontra a Classe javax.servlet

Olá, adicionei meu projeto no tomcat da versão mais recente, só que não encotra a classe HttpServlet. Como faço?

9 respostas

Qual erro aparece no console ? Qual o código do seu servlet ? Você importou todas as classes ?

Segue como está meu console.

Description    Resource    Path    Location    Type
Cookie cannot be resolved to a type    Cookies.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 7    Java Problem
Cookie cannot be resolved to a type    Cookies.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 9    Java Problem
Cookie cannot be resolved to a type    Cookies.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 10    Java Problem
Cookie cannot be resolved to a type    Cookies.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 13    Java Problem
Cookie cannot be resolved to a type    Cookies.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 14    Java Problem
Cookie cannot be resolved to a type    Cookies.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 15    Java Problem
Cookie cannot be resolved to a type    Cookies.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 15    Java Problem
Filter cannot be resolved to a type    FiltroDeAuditoria.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 17    Java Problem
FilterChain cannot be resolved to a type    FiltroDeAuditoria.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 25    Java Problem
FilterConfig cannot be resolved to a type    FiltroDeAuditoria.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 41    Java Problem
HttpServlet cannot be resolved to a type    Controller.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 13    Java Problem
HttpServlet cannot be resolved to a type    Login.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 20    Java Problem
HttpServlet cannot be resolved to a type    NovaEmpresa.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 17    Java Problem
HttpServletRequest cannot be resolved to a type    BuscaEmpresa.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 18    Java Problem
HttpServletRequest cannot be resolved to a type    Controller.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 16    Java Problem
HttpServletRequest cannot be resolved to a type    FiltroDeAuditoria.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 26    Java Problem
HttpServletRequest cannot be resolved to a type    FiltroDeAuditoria.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 26    Java Problem
HttpServletRequest cannot be resolved to a type    FiltroDeAuditoria.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 34    Java Problem
HttpServletRequest cannot be resolved to a type    Login.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 23    Java Problem
HttpServletRequest cannot be resolved to a type    Logout.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 9    Java Problem
HttpServletRequest cannot be resolved to a type    NovaEmpresa.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 20    Java Problem
HttpServletRequest cannot be resolved to a type    Tarefa.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 8    Java Problem
HttpServletResponse cannot be resolved to a type    BuscaEmpresa.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 18    Java Problem
HttpServletResponse cannot be resolved to a type    Controller.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 16    Java Problem
HttpServletResponse cannot be resolved to a type    Login.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 23    Java Problem
HttpServletResponse cannot be resolved to a type    Logout.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 9    Java Problem
HttpServletResponse cannot be resolved to a type    NovaEmpresa.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 20    Java Problem
HttpServletResponse cannot be resolved to a type    Tarefa.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 8    Java Problem
HttpSession cannot be resolved to a type    Login.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 32    Java Problem
RequestDispatcher cannot be resolved to a type    Controller.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 29    Java Problem
RequestDispatcher cannot be resolved to a type    NovaEmpresa.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 25    Java Problem
ServletException cannot be resolved to a type    Controller.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 17    Java Problem
ServletException cannot be resolved to a type    Controller.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 33    Java Problem
ServletException cannot be resolved to a type    FiltroDeAuditoria.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 25    Java Problem
ServletException cannot be resolved to a type    FiltroDeAuditoria.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 41    Java Problem
ServletException cannot be resolved to a type    Login.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 24    Java Problem
ServletException cannot be resolved to a type    NovaEmpresa.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 20    Java Problem
ServletRequest cannot be resolved to a type    FiltroDeAuditoria.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 24    Java Problem
ServletResponse cannot be resolved to a type    FiltroDeAuditoria.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 24    Java Problem
Target runtime Apache Tomcat v7.0 is not defined.    gerenciador        Unknown    Faceted Project Problem
The import javax.servlet.annotation cannot be resolved    Controller.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 7    Java Problem
The import javax.servlet.annotation cannot be resolved    FiltroDeAuditoria.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 11    Java Problem
The import javax.servlet.annotation cannot be resolved    Login.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 9    Java Problem
The import javax.servlet.annotation cannot be resolved    NovaEmpresa.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 8    Java Problem
The import javax.servlet.Filter cannot be resolved    FiltroDeAuditoria.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 5    Java Problem
The import javax.servlet.FilterChain cannot be resolved    FiltroDeAuditoria.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 6    Java Problem
The import javax.servlet.FilterConfig cannot be resolved    FiltroDeAuditoria.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 7    Java Problem
The import javax.servlet.http cannot be resolved    BuscaEmpresa.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 5    Java Problem
The import javax.servlet.http cannot be resolved    BuscaEmpresa.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 6    Java Problem
The import javax.servlet.http cannot be resolved    Controller.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 8    Java Problem
The import javax.servlet.http cannot be resolved    Controller.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 9    Java Problem
The import javax.servlet.http cannot be resolved    Controller.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 10    Java Problem
The import javax.servlet.http cannot be resolved    Cookies.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 3    Java Problem
The import javax.servlet.http cannot be resolved    FiltroDeAuditoria.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 12    Java Problem
The import javax.servlet.http cannot be resolved    Login.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 10    Java Problem
The import javax.servlet.http cannot be resolved    Login.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 11    Java Problem
The import javax.servlet.http cannot be resolved    Login.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 12    Java Problem
The import javax.servlet.http cannot be resolved    Login.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 13    Java Problem
The import javax.servlet.http cannot be resolved    Login.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 14    Java Problem
The import javax.servlet.http cannot be resolved    Logout.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 3    Java Problem
The import javax.servlet.http cannot be resolved    Logout.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 4    Java Problem
The import javax.servlet.http cannot be resolved    NovaEmpresa.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 9    Java Problem
The import javax.servlet.http cannot be resolved    NovaEmpresa.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 10    Java Problem
The import javax.servlet.http cannot be resolved    NovaEmpresa.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 11    Java Problem
The import javax.servlet.http cannot be resolved    Tarefa.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 3    Java Problem
The import javax.servlet.http cannot be resolved    Tarefa.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 4    Java Problem
The import javax.servlet.RequestDispatcher cannot be resolved    Controller.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 5    Java Problem
The import javax.servlet.RequestDispatcher cannot be resolved    NovaEmpresa.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 6    Java Problem
The import javax.servlet.ServletException cannot be resolved    Controller.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 6    Java Problem
The import javax.servlet.ServletException cannot be resolved    FiltroDeAuditoria.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 8    Java Problem
The import javax.servlet.ServletException cannot be resolved    Login.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 8    Java Problem
The import javax.servlet.ServletException cannot be resolved    NovaEmpresa.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 7    Java Problem
The import javax.servlet.ServletRequest cannot be resolved    FiltroDeAuditoria.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 9    Java Problem
The import javax.servlet.ServletResponse cannot be resolved    FiltroDeAuditoria.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 10    Java Problem
The method destroy() of type FiltroDeAuditoria must override or implement a supertype method    FiltroDeAuditoria.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 20    Java Problem
The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path    buscaEmpresa.jsp    /gerenciador/WebContent/WEB-INF/paginas    line 1    JSP Problem
The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path    buscaEmpresa.jsp    /gerenciador/WebContent/WEB-INF/paginas    line 1    JSP Problem
The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path    index.jsp    /gerenciador/WebContent    line 1    JSP Problem
The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path    index.jsp    /gerenciador/WebContent    line 1    JSP Problem
The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path    novaEmpresa.jsp    /gerenciador/WebContent/WEB-INF/paginas    line 1    JSP Problem
The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path    novaEmpresa.jsp    /gerenciador/WebContent/WEB-INF/paginas    line 1    JSP Problem
The type BuscaEmpresa must implement the inherited abstract method Tarefa.executa(HttpServletRequest, HttpServletResponse)    BuscaEmpresa.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 11    Java Problem
The type Logout must implement the inherited abstract method Tarefa.executa(HttpServletRequest, HttpServletResponse)    Logout.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 6    Java Problem
WebFilter cannot be resolved to a type    FiltroDeAuditoria.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 16    Java Problem
WebServlet cannot be resolved to a type    Controller.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 12    Java Problem
WebServlet cannot be resolved to a type    Login.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 19    Java Problem
WebServlet cannot be resolved to a type    NovaEmpresa.java    /gerenciador/src/main/java/br/com/alura/gerenciador/web    line 16    Java Problem
The tag handler class for "c:forEach" (org.apache.taglibs.standard.tag.rt.core.ForEachTag) was not found on the Java Build Path    buscaEmpresa.jsp    /gerenciador/WebContent/WEB-INF/paginas    line 7    JSP Problem
The tag handler class for "c:if" (org.apache.taglibs.standard.tag.rt.core.IfTag) was not found on the Java Build Path    index.jsp    /gerenciador/WebContent    line 6    JSP Problem

O que gerou este erro ? Foi a chamada da servlet ? O servidor estava rodando quando surgiu o erro?

Você precisa "startar" o servidor antes de invocar a "aplicação" via browser.

Consegui rodar minha primeira página, mais todas as classes que estende HttpServlet, não encontra a classe. Estou usando o Tomcat sendo a ultima versão que no caso Hoje é a 9.0.

O seu eclipse está procurando o TOMCAT 7.

Veja a mensagem de erro.

runtime Apache Tomcat v7.0 is not defined.

Resolvido Obrigado!

Boa noite Davyson,

Eu estou com mesmo problema, penso que não está encontrando por causa da versão do tomcat mesmo. Estou usando a versão 8.50 com jdk 8... será que é isso ?

Gustavo, o problema não é esse é necessário adicionar a Servlet Api no ser projeto para que funcione.

Irlan,

Exatamente, é só baixar o jar da Servlet. Eu tinha viajado.

Obrigado.

Abraços.