5
respostas

Exception ao acessar a home.jsp

Olá Pessoal,

Estou encontrando problema ao acessar a home do projeto, o Tomcat inicia normalmente, passa pelo controller e ao acessar o localhost:8080/casadocodigo/ estou recebendo a seguinte Exception:

type Exception report

message Unable to compile class for JSP:

description The server encountered an internal error that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 1 in the generated java file
The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files

An error occurred at line: 1 in the generated java file
The type java.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .class files

O home.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
    <h1>Casa do Código</h1>
</body>
</html>

E demais classes:

@Controller
public class HomeController {

    @RequestMapping("/")
    public String index() {
        System.out.println("Entrando na Home com CDC");
        return "home";
    }
}
public class ServletSpringMVC extends AbstractAnnotationConfigDispatcherServletInitializer {

    @Override
    protected Class<?>[] getRootConfigClasses() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    protected Class<?>[] getServletConfigClasses() {
        // TODO Auto-generated method stub
        return new Class[] {AppWebConfiguration.class};
    }

    @Override
    protected String[] getServletMappings() {
        // TODO Auto-generated method stub
        return new String[] {"/"};
    }

}
@EnableWebMvc
@ComponentScan(basePackageClasses={HomeController.class})
public class AppWebConfiguration {

    @Bean
    public InternalResourceViewResolver internalResourceViewResolver() {
        InternalResourceViewResolver resolver = new InternalResourceViewResolver();
        resolver.setPrefix("WEB-INF/views/");
        resolver.setSuffix(".jsp");
        return resolver;
    }
}
5 respostas

Olá jeferson, você já tentou colocar o nome do JSP de forma explicita?

Algo parecido com o exemplo abaixo:

localhost:8080/casadocodigo/home.jsp

Jeferson, coloca uma "/" antes de WEB-INF:

viewResolver.setPrefix("/WEB-INF/paginas/");

@Denis,

Tentei acessar dessa forma e recebo um 404.

message /casadocodigo/home.jsp

description The requested resource is not available.

@guilherme,

Inseri a barra e apresenta o mesmo exception...

@Denis,

Consegui acessar a home mudando o projeto para o tomcat 9.

Não entendi o motivo.

Tive o mesmo problema. Instalei o tomcat 8. e funcionou! vlw!