3
respostas

HTTP Status 404 - Meu projeto não sobe!

Alguém pode me ajudar ?

Mar 10, 2017 10:41:03 PM org.apache.catalina.core.AprLifecycleListener init
INFORMAÇÕES: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre7\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\wamp\bin\php\php5.5.12;C:\ProgramData\ComposerSetup\bin;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files\Microsoft SQL Server\120\DTS\Binn\;C:\Users\Alessandro\AppData\Local\Microsoft\WindowsApps;C:\Users\Alessandro\AppData\Roaming\Composer\vendor\bin;C:\wamp\bin\php\php5.5.12;C:\php\pear;.
Mar 10, 2017 10:41:03 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
ADVERTÊNCIA: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:casadocodigo' did not find a matching property.
Mar 10, 2017 10:41:03 PM org.apache.coyote.AbstractProtocolHandler init
INFORMAÇÕES: Initializing ProtocolHandler ["http-bio-8080"]
Mar 10, 2017 10:41:03 PM org.apache.coyote.AbstractProtocolHandler init
INFORMAÇÕES: Initializing ProtocolHandler ["ajp-bio-8009"]
Mar 10, 2017 10:41:03 PM org.apache.catalina.startup.Catalina load
INFORMAÇÕES: Initialization processed in 959 ms
Mar 10, 2017 10:41:03 PM org.apache.catalina.core.StandardService startInternal
INFORMAÇÕES: Starting service Catalina
Mar 10, 2017 10:41:03 PM org.apache.catalina.core.StandardEngine startInternal
INFORMAÇÕES: Starting Servlet Engine: Apache Tomcat/7.0.12
Mar 10, 2017 10:41:03 PM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFORMAÇÕES: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [116] milliseconds.
Mar 10, 2017 10:41:09 PM org.apache.catalina.core.ApplicationContext log
INFORMAÇÕES: Spring WebApplicationInitializers detected on classpath: [br.com.casadocodigo.loja.conf.ServletSpringMVC@7a601e4]
log4j:WARN No appenders could be found for logger (br.com.casadocodigo.loja.conf.ServletSpringMVC).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Mar 10, 2017 10:41:09 PM org.apache.coyote.AbstractProtocolHandler start
INFORMAÇÕES: Starting ProtocolHandler ["http-bio-8080"]
Mar 10, 2017 10:41:09 PM org.apache.coyote.AbstractProtocolHandler start
INFORMAÇÕES: Starting ProtocolHandler ["ajp-bio-8009"]
Mar 10, 2017 10:41:09 PM org.apache.catalina.startup.Catalina start
INFORMAÇÕES: Server startup in 6185 ms
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>br.com.casadocodigo.loja</groupId>
  <artifactId>casadocodigo</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>

    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>4.1.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-servlet-api</artifactId>
            <version>7.0.30</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp.jstl</groupId>
            <artifactId>jstl-api</artifactId>
            <version>1.2</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.servlet</groupId>
                    <artifactId>servlet-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.glassfish.web</groupId>
            <artifactId>jstl-impl</artifactId>
            <version>1.2</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.servlet</groupId>
                    <artifactId>servlet-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.6.1</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>1.6.1</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.6.1</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.16</version>
            <scope>runtime</scope>
        </dependency>
    </dependencies>


    <build>
        <finalName>casadocodigo</finalName>
    </build>
    <properties>
        <failOnMissingWebXml>false</failOnMissingWebXml>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

</project>
<%@ 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>Livros de Java, Android, iPhone, Ruby, PHP e muito mais - Casa do Código</title>
</head>
<body>
<h1>Casa do Código</h1>
<table>
    <tr>
        <td>TDD na Prática - JAVA</td>
        <td>Google Android</td>
        <td>Certificação OCJP</td>
        <td>Java 8 Prático</td>
    </tr>
</table>
</body>
</html>

package br.com.casadocodigo.loja.controllers;

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

@Controller public class HomeController{

@RequestMapping("/") public String index(){ System.out.println("Entrando na home da CDC"); return "home.jsp"; } }

package br.com.casadocodigo.loja.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.loja.controllers.HomeController;

@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;
    }
}

package br.com.casadocodigo.loja.conf;

import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

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[] {"/"}; }

}

3 respostas

Boa noite Letícia,

Com você já configurou seu AppWebConfiguration, no método internalResourceViewResolve o resolve.setSuffix(".jsp");

Não precisa usar no retorno da classe HomeController:

return "home.jsp";

Use o somente:

return "home";

Teste e veja se funfa.

Não funcionou fazendo essa alteração. Eu já assisti as aulas umas 10 vezes e comparei meu código com o exercício umas 7 vezes. Eu acho que pode ser algum problema de configuração do meu Eclipse, já estou parado uns 3 dias e não consigo passar dessa aula.

Disponibiliza seu projeto no GitHub que testo pra você.