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

HTTP Status 404 - /alura-horas/

Digito a url :http://localhost:8080/alura-horas/ e da um 404.

IndexController

package br.com.alura.horas.controllers;

import br.com.caelum.vraptor.Controller;
import br.com.caelum.vraptor.Path;

@Controller
public class IndexController {


    @Path("/")
    public void index(){
    }
}

pom.xml

<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.caelum</groupId>
    <artifactId>alura-horas</artifactId>
    <version>4.1.1</version>
    <packaging>war</packaging>

    <description>A blank project to start using VRaptor 4</description>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <weld.version>2.1.2.Final</weld.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>br.com.caelum</groupId>
            <artifactId>vraptor</artifactId>
            <version>4.1.1</version>
        </dependency>

        <dependency>
            <groupId>org.jboss.weld.servlet</groupId>
            <artifactId>weld-servlet-core</artifactId>
            <version>2.1.2.Final</version>
        </dependency>

        <dependency>
            <groupId>org.jboss.weld</groupId>
            <artifactId>weld-core-impl</artifactId>
            <version>2.1.2.Final</version>
        </dependency>

        <dependency>
            <groupId>javax.el</groupId>
            <artifactId>el-api</artifactId>
            <version>2.2</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator-cdi</artifactId>
            <version>5.1.1.Final</version>
        </dependency>

        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
            <!-- uncomment this line on app servers -->
            <!-- <scope>provided</scope> -->
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>4.3.6.Final</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.33</version>
        </dependency>
    </dependencies>

    <build>
        <finalName>alura-horas</finalName>
        <outputDirectory>${basedir}/src/main/webapp/WEB-INF/classes</outputDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <path>/</path>
                </configuration>
            </plugin>

        </plugins>
    </build>
</project>
10 respostas

Oi Renato, tudo certo?

pode acessar a página (que vai dar um 404) e verificar no log do tomcat se está dando algum erro e postar aqui?

abraços!

tomcat

mai 15, 2017 3:16:31 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:alura-horas' did not find a matching property.
mai 15, 2017 3:16:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Server version:        Apache Tomcat/7.0.77
mai 15, 2017 3:16:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Server built:          Mar 28 2017 16:01:48 UTC
mai 15, 2017 3:16:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Server number:         7.0.77.0
mai 15, 2017 3:16:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: OS Name:               Windows 7
mai 15, 2017 3:16:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: OS Version:            6.1
mai 15, 2017 3:16:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Architecture:          amd64
mai 15, 2017 3:16:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Java Home:             C:\Program Files\Java\jdk1.8.0_131\jre
mai 15, 2017 3:16:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: JVM Version:           1.8.0_131-b11
mai 15, 2017 3:16:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: JVM Vendor:            Oracle Corporation
mai 15, 2017 3:16:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: CATALINA_BASE:         C:\Users\Renato\workspace\vraptor\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
mai 15, 2017 3:16:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: CATALINA_HOME:         C:\Users\Renato\workspace\vraptor\apache-tomcat-7.0.77
mai 15, 2017 3:16:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dcatalina.base=C:\Users\Renato\workspace\vraptor\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
mai 15, 2017 3:16:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dcatalina.home=C:\Users\Renato\workspace\vraptor\apache-tomcat-7.0.77
mai 15, 2017 3:16:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dwtp.deploy=C:\Users\Renato\workspace\vraptor\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
mai 15, 2017 3:16:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Djava.endorsed.dirs=C:\Users\Renato\workspace\vraptor\apache-tomcat-7.0.77\endorsed
mai 15, 2017 3:16:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dfile.encoding=Cp1252
mai 15, 2017 3:16:31 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
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\jdk1.8.0_131\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jdk1.8.0_131/jre/bin/server;C:/Program Files/Java/jdk1.8.0_131/jre/bin;C:/Program Files/Java/jdk1.8.0_131/jre/lib/amd64;C:\Windows\system32;C:\Windows;C:\Windows\system32\wbem;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Java\jdk1.8.0_131\\bin;C:\Users\Renato\Desktop;;.
mai 15, 2017 3:16:31 PM org.apache.coyote.AbstractProtocol init
INFORMAÇÕES: Initializing ProtocolHandler ["http-bio-8080"]
mai 15, 2017 3:16:32 PM org.apache.coyote.AbstractProtocol init
INFORMAÇÕES: Initializing ProtocolHandler ["ajp-bio-8009"]
mai 15, 2017 3:16:32 PM org.apache.catalina.startup.Catalina load
INFORMAÇÕES: Initialization processed in 1059 ms
mai 15, 2017 3:16:32 PM org.apache.catalina.core.StandardService startInternal
INFORMAÇÕES: Starting service Catalina
mai 15, 2017 3:16:32 PM org.apache.catalina.core.StandardEngine startInternal
INFORMAÇÕES: Starting Servlet Engine: Apache Tomcat/7.0.77
mai 15, 2017 3:16:34 PM org.apache.catalina.loader.WebappClassLoaderBase validateJarFile
INFORMAÇÕES: validateJarFile(C:\Users\Renato\workspace\vraptor\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\alura-horas\WEB-INF\lib\jboss-el-api_3.0_spec-1.0.0.Alpha1.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/el/Expression.class
mai 15, 2017 3:16:35 PM org.apache.catalina.startup.TldConfig execute
INFORMAÇÕES: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
mai 15, 2017 3:16:35 PM org.jboss.weld.bootstrap.WeldStartup <clinit>
INFO: WELD-000900: 2.1.2 (Final)
mai 15, 2017 3:16:35 PM org.jboss.weld.bootstrap.WeldStartup startContainer
INFO: WELD-000101: Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
mai 15, 2017 3:16:36 PM org.hibernate.validator.internal.util.Version <clinit>
INFO: HV000001: Hibernate Validator 5.1.1.Final
mai 15, 2017 3:16:44 PM org.jboss.weld.environment.tomcat7.Tomcat7Container initialize
INFO: Tomcat 7+ detected, CDI injection will be available in Servlets and Filters. Injection into Listeners is not supported
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
mai 15, 2017 3:16:46 PM org.apache.coyote.AbstractProtocol start
INFORMAÇÕES: Starting ProtocolHandler ["http-bio-8080"]
mai 15, 2017 3:16:47 PM org.apache.coyote.AbstractProtocol start
INFORMAÇÕES: Starting ProtocolHandler ["ajp-bio-8009"]
mai 15, 2017 3:16:47 PM org.apache.catalina.startup.Catalina start
INFORMAÇÕES: Server startup in 15073 ms

Oi Renato, não parece ter qualquer erro...

você pode me enviar seu projeto, subindo no github ou zipando e subindo no dropbox, e por o link aqui, pra eu tentar rodar no meu computador?

abraço!

tentei começar do zero novamente, parece que meu pom.xml está estranho. sera que você consegue identificar o que está errado ?

<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>your.groupid</groupId>
    <artifactId>your-artifactid</artifactId>
    <version>1.0.0</version>
    <packaging>war</packaging>

    <description>A blank project to start using VRaptor 4</description>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <weld.version>2.1.2.Final</weld.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>br.com.caelum</groupId>
            <artifactId>vraptor</artifactId>
            <version>4.1.1</version>
        </dependency>

        <dependency>
            <groupId>org.jboss.weld.servlet</groupId>
            <artifactId>weld-servlet-core</artifactId>
            <version>2.1.2.Final</version>
        </dependency>

        <dependency>
            <groupId>org.jboss.weld</groupId>
            <artifactId>weld-core-impl</artifactId>
            <version>2.1.2.Final</version>
        </dependency>

        <dependency>
            <groupId>javax.el</groupId>
            <artifactId>el-api</artifactId>
            <version>2.2</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator-cdi</artifactId>
            <version>5.1.1.Final</version>
        </dependency>

        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
            <!-- uncomment this line on app servers -->
            <!-- <scope>provided</scope> -->
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
    </dependencies>

    <build>
        <finalName>vraptor-blank-project</finalName>
        <outputDirectory>c:\Users\Victor\vraptor4\vraptor-blank-project/src/main/webapp/WEB-INF/classes</outputDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <path>/</path>
                </configuration>
            </plugin>

        </plugins>
    </build>
</project>

agora aparece erro 500 http://localhost:8080/alura-horas/

java.lang.IllegalStateException: There are two rules that matches the uri '/' with method GET: [FixedMethodStrategy: /                                                                 index                                                                  ALL], [FixedMethodStrategy: /                                                                 index                                                                  ALL] with same priority. Consider using @Path priority attribute.
    com.google.common.base.Preconditions.checkState(Preconditions.java:177)
    br.com.caelum.vraptor.http.route.DefaultRouter.checkIfThereIsAnotherRoute(DefaultRouter.java:124)
    br.com.caelum.vraptor.http.route.DefaultRouter.parse(DefaultRouter.java:116)
    br.com.caelum.vraptor.http.route.DefaultRouter$Proxy$_$$_WeldClientProxy.parse(Unknown Source)
    br.com.caelum.vraptor.http.DefaultControllerTranslator.translate(DefaultControllerTranslator.java:63)
    br.com.caelum.vraptor.http.DefaultControllerTranslator$Proxy$_$$_WeldClientProxy.translate(Unknown Source)
    br.com.caelum.vraptor.observer.RequestHandlerObserver.handle(RequestHandlerObserver.java:91)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    java.lang.reflect.Method.invoke(Unknown Source)
    org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:93)
    org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:266)
    org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:253)
    org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:232)
    org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:169)
    org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:165)
    org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:119)
    org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:112)
    org.jboss.weld.event.EventImpl.fire(EventImpl.java:83)
    br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:118)

meu indexController

package br.com.alura.horas.controller;

import br.com.caelum.vraptor.Controller;
import br.com.caelum.vraptor.Path;

@Controller
public class IndexController {

    @Path("/")
    public void index(){

    }
}

meu pom

<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>your.groupid</groupId>
    <artifactId>alura-horas</artifactId>
    <version>1.0.0</version>
    <packaging>war</packaging>

    <description>A blank project to start using VRaptor 4</description>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <weld.version>2.1.2.Final</weld.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>br.com.caelum</groupId>
            <artifactId>vraptor</artifactId>
            <version>4.1.1</version>
        </dependency>

        <dependency>
            <groupId>org.jboss.weld.servlet</groupId>
            <artifactId>weld-servlet-core</artifactId>
            <version>2.1.2.Final</version>
        </dependency>

        <dependency>
            <groupId>org.jboss.weld</groupId>
            <artifactId>weld-core-impl</artifactId>
            <version>2.1.2.Final</version>
        </dependency>

        <dependency>
            <groupId>javax.el</groupId>
            <artifactId>el-api</artifactId>
            <version>2.2</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator-cdi</artifactId>
            <version>5.1.1.Final</version>
        </dependency>

        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
            <!-- uncomment this line on app servers -->
            <!-- <scope>provided</scope> -->
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
    </dependencies>

    <build>
        <finalName>vraptor-blank-project</finalName>
        <outputDirectory>c:\Users\Victor\vraptor4\vraptor-blank-project/src/main/webapp/WEB-INF/classes</outputDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <path>/</path>
                </configuration>
            </plugin>

        </plugins>
    </build>
</project>

minha jsp

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Bem vindo!</title>
</head>
<body>
<h1>Sistema de controle de Horas</h1>
</body>
</html>

Oi Renato, tem algum outro Controller, no seu projeto?

ele está dizendo que existem duas URIs que mapeiam /, no caso tem dois métodos que podem atender quando vc acessa localhost:8080/alura-horas/.

Lucas obrigado pela ajuda, mais já me irritei com este projeto utilizando vraptor. não irei fazer este curso mais. Irei procurar algum outro mas mesmo assim obrigado !

solução!

Oi Renato,

Se você deseja continuar, a melhor forma de resolver esse problema é usar o http://www.setupmyproject.com/, é um site que em que é montado o projeto inicial para você não ter problemas com isso.

Realmente o vraptor é muito chato para começara configuração inicial =´[

abraço

No seu POM.xml está assim:

<finalName>vraptor-blank-project</finalName>
<outputDirectory>c:\Users\Victor\vraptor4\vraptor-blank-project/src/main/webapp/WEB-INF/classes</outputDirectory>

Troque para:

 <finalName>alura-horas</finalName>
<outputDirectory>${basedir}/src/main/webapp/WEB-INF/classes</outputDirectory>

Realmente, acho que o startup do curso no que diz respeito ao projeto inicial foi não feliz em utilizar esse vraptor-blank-project, eu baixei esse projeto inicial e ele veio com algumas pastas do windows, como c: etc além da configuração mencionada, isso confunde um pouco quem ta iniciando com o framework.

No meu caso eu criei um projeto Maven default através do Eclipse e ainda tem uma estrutura de pastas diferente da abordada no curso. Fui pra sugestão do setupmyproject e deu certo. Vou continuar com a estrutura gerada por ele então...