Fiz o projeto desde o início funcionando perfeitamente, quando chegou na parte "Melhorando o controlador", dá pau.
Já peguei o projeto do instrutor e continua dando o mesmo erro.
Minha classe
package br.com.caelum.gerenciador.servlet;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import br.com.caelum.gerenciador.acao.Acao;
@WebServlet("/entrada")
public class UnicaEntradaServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String paramAcao = request.getParameter("acao");
String nomeDaClasse = "br.com.caelum.gerenciador.acao." + paramAcao;
String nome;
try {
Class classe = Class.forName(nomeDaClasse);//carrega a classe com o nome
Acao acao = (Acao) classe.newInstance();
nome = acao.executa(request,response);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
throw new ServletException(e);
}
String[] tipoEEndereco = nome.split(":");
if(tipoEEndereco[0].equals("forward")) {
RequestDispatcher rd = request.getRequestDispatcher("WEB-INF/view/" + tipoEEndereco[1]);
rd.forward(request, response);
} else {
response.sendRedirect(tipoEEndereco[1]);
}
//paramAcao.executa(req,res)
}
}
Erro
mar 28, 2020 1:07:35 AM org.apache.catalina.core.StandardWrapperValve invoke
GRAVE: Servlet.service() for servlet [br.com.caelum.gerenciador.servlet.UnicaEntradaServlet] in context with path [/gerenciador] threw exception [java.lang.ClassNotFoundException: br.com.caelum.gerenciador.acao.listaEmpresas] with root cause
java.lang.ClassNotFoundException: br.com.caelum.gerenciador.acao.listaEmpresas
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1365)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1188)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at br.com.caelum.gerenciador.servlet.UnicaEntradaServlet.service(UnicaEntradaServlet.java:27)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at