Estou tentado listar empresas (aula Listando empresas com servlets) Retorna erro na linha : throws ServletException, IOException { Mensagem: " No exception of type ServletException can be thrown; an exception type must be a subclass of Throwable Solicito ajuda". Tks
package br.com.alura.gerenciador.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import javax.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
/**
* Servlet implementation class ListaEmpresas
*/
@WebServlet("/listaEmpresas")
public class ListaEmpresasServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
Banco banco = new Banco();
List<Empresa> lista = banco.getEmpresas();
PrintWriter out = response.getWriter();
out.println("<html><body>");
out.println("<ul>");
for (Empresa empresa : lista) {
out.println("<li> " + empresa.getNome() + "</li>");
}
out.println("</ul>");
out.println("</body></html>");
}
}
Erro: No exception of type ServletException can be thrown; an exception type must be a subclass of Throwable Solicito ajuda. Tks