Solucionado (ver solução)
Solucionado
(ver solução)
9
respostas

Problemas com a iniciação do servidor após criar a jsp

Boa tarde!

Ao tentat acessar o pagina home.jsp (localhost:8080/casadocodigo) acontece 404 - not found.

Configurei o projeto igual ao que é apresentado no curso, a unica diferença é que não utilizei o forge para criar o projeto, então a minha pagina jsp esta dentro da WebContent> WEB-INF>views.

Segue log ao iniciar o servidor tomcat 8.5.16:

jul 03, 2017 1:19:11 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:casadocodigo' did not find a matching property.
jul 03, 2017 1:19:11 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version:        Apache Tomcat/8.5.16
jul 03, 2017 1:19:11 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built:          Jun 21 2017 17:01:09 UTC
jul 03, 2017 1:19:11 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number:         8.5.16.0
jul 03, 2017 1:19:11 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name:               Linux
jul 03, 2017 1:19:11 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version:            4.8.0-58-generic
jul 03, 2017 1:19:11 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture:          amd64
jul 03, 2017 1:19:11 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home:             /usr/lib/jvm/java-8-openjdk-amd64/jre
jul 03, 2017 1:19:11 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version:           1.8.0_131-8u131-b11-0ubuntu1.16.04.2-b11
jul 03, 2017 1:19:11 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor:            Oracle Corporation
jul 03, 2017 1:19:11 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE:         /home/thales/eclipse-workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0
jul 03, 2017 1:19:11 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME:         /home/thales/Downloads/apache-tomcat-8.5.16
jul 03, 2017 1:19:11 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=/home/thales/eclipse-workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0
jul 03, 2017 1:19:11 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=/home/thales/Downloads/apache-tomcat-8.5.16
jul 03, 2017 1:19:11 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=/home/thales/eclipse-workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps
jul 03, 2017 1:19:11 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=/home/thales/Downloads/apache-tomcat-8.5.16/endorsed
jul 03, 2017 1:19:11 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=UTF-8
jul 03, 2017 1:19:11 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib]
jul 03, 2017 1:19:11 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
jul 03, 2017 1:19:11 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
jul 03, 2017 1:19:11 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-nio-8009"]
jul 03, 2017 1:19:11 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
jul 03, 2017 1:19:11 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 902 ms
jul 03, 2017 1:19:11 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service [Catalina]
jul 03, 2017 1:19:11 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.5.16
jul 03, 2017 1:19:12 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
jul 03, 2017 1:19:12 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8009"]
jul 03, 2017 1:19:12 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 610 ms
9 respostas

Oi Thales, tudo bem ?

Cara aparentemente o servidor subiu e não teve nenhum problema, você chegou a levar alguma exception ao entrar ?

ele não apresenta nada, o problema é quando tento carregar a paagina. Apresenta o sguinte;

HTTP Status 404 – Not Found

Type Status Report

Message /casadocodigo/

Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

Thales, você tem um controller ouvindo o que ?

Segue como esta meu controller:

package br.com.casadocodigo.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class HomeController {

    @RequestMapping("/")
    public String index() {
        System.out.println("[-INFO-] Entrando na home CDC");

        return "home";
    }

}

Existe algum arquivo chamado home ?

tem sim, o caminho para o arquivo home.jsp esta assim: casadocodigo>WebContent>WEB-INF>views>home.jsp

o meu AppWebConfiguration esta assim:

package br.com.casadocodigo.conf;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

import br.com.casadocodigo.controller.HomeController;

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

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

    }
}

    public InternalResourceViewResolver internalResourceViewResolve() {
        InternalResourceViewResolver resolve = new InternalResourceViewResolver();
        resolve.setPrefix("/WEB-INF/views/");
        resolve.setSuffix(".jsp");
        return resolve;
    }

Tenta dessa forma

Ainda continua com o mesmo problema ao tentar acessar o local host

solução!

Bom dia, criei novamente o projeto só que agora pelo forge e consegui fazer aparecer a jsp. Aparentemente era algo ligado com o mapemento da pagina. Queria saber apenas como realizo este mapeamento criando um projeto maven direto pela IDE, pois o meu não funcionou quando fiz assim