VRaptor retorna 403 ao tentar acessar controller

3 respostas
back-endjbossframeworkjava
A

Boa tarde pessoal, estou com um problema que nunca tinha acontecido comigo. Tenho uma aplicação com VRaptor 4 e Wildfly 10 no eclipse neon, a princípio está tudo configurado corretamente inclusive tenho outras aplicações que funcionam. Está acontecendo o seguinte, meus controllers não são invocados.

MEU 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>ControleEstoque</groupId>
  <artifactId>ControleEstoque</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <name>ControleEstoque</name>
  <description>Controle de estoque</description>
  
  <build>
  		<finalName>ControleEstoque</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.0</version>
                <configuration>
                	<fork>true</fork>
                    <source>1.8</source>
                    <target>1.8</target>
                    <compilerArgument>-parameters</compilerArgument>
                    <testCompilerArgument>-parameters</testCompilerArgument>
                </configuration>
            </plugin>
        </plugins>
  </build>
  
  <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  
  <dependencies>
        <!-- Dependência do VRAPTOR 4.2.0-RC3 -->
        <dependency>
            <groupId>br.com.caelum</groupId>
            <artifactId>vraptor</artifactId>
            <version>4.2.0-RC3</version>
        </dependency>
        
        <dependency>
		    <groupId>br.com.caelum.vraptor</groupId>
		    <artifactId>vraptor-java8</artifactId>
		    <version>4.0.0.Final</version>
		</dependency>
        
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
            <scope>provided</scope>
        </dependency>
        
        <!--  -->
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
   		</dependency>
   </dependencies>
</project>

MEU beans.xml(está dentro da pasta WEB-INF)
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
       bean-discovery-mode="all">
</beans>

Meu login.jsp(está dentro de WEB-INF/jsp/login)
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html>
<html>
  <head>
    <title>teste</title>
	<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  </head>
  <body>
  	${msg}
  </body>
</html>	
	
Menu LoginController.java
package controller;

import javax.inject.Inject;

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

@Controller
public class LoginController {
	@Inject private Result result;

	public void login(){
		result.include("msg", "Está funcionando");
	}
	
}

3 Respostas

I

No network do console, ele pega a url certinho ?

A

Aparentemente sim, quando atualizei o eclipse para o neon e o wildfly para a versão 10 tive que começar a acessar com a versão do snapshot tipo localhost:8080/teste-0.0.1-SNAPSHOT/. Mas aí adicionei o arquivo jboss-web.xml dentro de WEB-INF e consegui somente com localhost:8080/teste/.

O servidor parece estar subindo normal

20:26:59,531 INFO  org.jboss.modules] (main) JBoss Modules version 1.5.2.Final

20:26:59,788 INFO  org.jboss.msc] (main) JBoss MSC version 1.2.6.Final

20:26:59,864 INFO  [<a href="http://org.jboss.as">org.jboss.as</a>] (MSC service thread 1-6) WFLYSRV0049: WildFly Full 10.1.0.Final (WildFly Core 2.2.0.Final) starting

20:27:01,415 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) WFLYDS0004: Found ControleEstoque-0.0.1-SNAPSHOT.war in deployment directory. To trigger deployment create a file called ControleEstoque-0.0.1-SNAPSHOT.war.dodeploy

20:27:01,467 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http)

20:27:01,492 INFO  [org.xnio] (MSC service thread 1-2) XNIO version 3.4.0.Final

20:27:01,501 INFO  [org.xnio.nio] (MSC service thread 1-2) XNIO NIO Implementation Version 3.4.0.Final

20:27:01,618 INFO  [org.jboss.as.naming] (ServerService Thread Pool  46) WFLYNAM0001: Activating Naming Subsystem

20:27:01,630 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool  38) WFLYCLINF0001: Activating Infinispan subsystem.

20:27:01,672 INFO  [org.jboss.as.security] (ServerService Thread Pool  53) WFLYSEC0002: Activating Security Subsystem

20:27:01,674 INFO  [org.jboss.as.webservices] (ServerService Thread Pool  56) WFLYWS0002: Activating WebServices Extension

20:27:01,682 WARN  [org.jboss.as.txn] (ServerService Thread Pool  54) WFLYTX0013: Node identifier property is set to the default value. Please make sure it is unique.

20:27:01,688 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-3) WFLYUT0003: Undertow 1.4.0.Final starting

20:27:01,703 INFO  [org.jboss.as.security] (MSC service thread 1-8) WFLYSEC0001: Current PicketBox version=4.9.6.Final

20:27:01,719 INFO  [org.jboss.as.jsf] (ServerService Thread Pool  44) WFLYJSF0007: Activated the following JSF Implementations: [main]

20:27:01,724 INFO  [org.jboss.as.naming] (MSC service thread 1-7) WFLYNAM0003: Starting Naming Service

20:27:01,728 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-7) WFLYMAIL0001: Bound mail session [java:jboss/mail/Default]

20:27:01,733 INFO  [org.jboss.as.connector] (MSC service thread 1-3) WFLYJCA0009: Starting JCA Subsystem (WildFly/IronJacamar 1.3.4.Final)

20:27:01,880 INFO  [<a href="http://org.wildfly.extension.io">org.wildfly.extension.io</a>] (ServerService Thread Pool  37) WFLYIO001: Worker ‘default’ has auto-configured to 8 core threads with 64 task threads based on your 4 available processors

20:27:01,921 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool  33) WFLYJCA0004: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)

20:27:01,946 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-4) WFLYJCA0018: Started Driver service with driver-name = h2

20:27:01,951 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool  33) WFLYJCA0005: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)

20:27:01,956 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-7) WFLYJCA0018: Started Driver service with driver-name = mysql

20:27:02,093 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool  55) WFLYUT0014: Creating file handler for path ‘S:\wildfly-10.1.0.Final/welcome-content’ with options [directory-listing: ‘false’, follow-symlink: ‘false’, case-sensitive: ‘true’, safe-symlink-paths: ‘[]’]

20:27:02,289 INFO  [org.jboss.as.ejb3] (MSC service thread 1-4) WFLYEJB0481: Strict pool slsb-strict-max-pool is using a max instance size of 64 (per class), which is derived from thread worker pool sizing.

20:27:02,290 INFO  [org.jboss.as.ejb3] (MSC service thread 1-8) WFLYEJB0482: Strict pool mdb-strict-max-pool is using a max instance size of 16 (per class), which is derived from the number of CPUs on this host.

20:27:02,448 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0012: Started server default-server.

20:27:02,449 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0018: Host default-host starting

20:27:02,526 INFO  [org.jboss.remoting] (MSC service thread 1-2) JBoss Remoting version 4.0.21.Final

20:27:02,582 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-4) WFLYUT0006: Undertow HTTP listener default listening on 127.0.0.1:8080

20:27:02,882 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-4) WFLYJCA0001: Bound data source [java:jboss/datasources/hookahrent]

20:27:02,883 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]

20:27:02,894 WARN  [org.jboss.as.domain.management.security] (MSC service thread 1-4) WFLYDM0111: Keystore S:\wildfly-10.1.0.Final\standalone\configuration\application.keystore not found, it will be auto generated on first use with a self signed certificate for host localhost

20:27:02,968 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-8) WFLYDS0013: Started FileSystemDeploymentService for directory S:\wildfly-10.1.0.Final\standalone\deployments

20:27:02,993 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) WFLYSRV0027: Starting deployment of “ControleEstoque-0.0.1-SNAPSHOT.war” (runtime-name: “ControleEstoque-0.0.1-SNAPSHOT.war”)

20:27:03,418 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-4) WFLYUT0006: Undertow HTTPS listener https listening on 127.0.0.1:8443

20:27:03,421 INFO  [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-7) ISPN000128: Infinispan version: Infinispan ‘Chakra’ 8.2.4.Final

20:27:03,485 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool  60) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.

20:27:03,487 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool  60) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.

20:27:03,567 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool  59) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.

20:27:03,569 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool  59) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.

20:27:03,572 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool  66) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.

20:27:03,573 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool  66) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.

20:27:03,777 INFO  [org.jboss.ws.common.management] (MSC service thread 1-4) JBWS022052: Starting JBossWS 5.1.5.Final (Apache CXF 3.1.6)

20:27:06,188 INFO  [org.jboss.weld.deployer] (MSC service thread 1-2) WFLYWELD0003: Processing weld deployment ControleEstoque-0.0.1-SNAPSHOT.war

20:27:06,272 INFO  [org.hibernate.validator.internal.util.Version] (MSC service thread 1-2) HV000001: Hibernate Validator 5.2.4.Final

20:27:06,669 INFO  [org.jboss.weld.Version] (MSC service thread 1-1) WELD-000900: 2.3.5 (Final)

20:27:07,741 INFO  [org.jboss.weld.Bootstrap] (Weld Thread Pool  1) WELD-001125: Illegal bean type interface java.util.Map<java.lang.Class<?>,class java.lang.Object> ignored on [EnhancedAnnotatedTypeImpl] public @ApplicationScoped <a class="mention" href="/u/named">@Named</a> class br.com.caelum.vraptor.view.LinkToHandler

20:27:07,770 INFO  [org.jboss.weld.Bootstrap] (Weld Thread Pool  1) WELD-001125: Illegal bean type com.google.common.collect.ForwardingMap<java.lang.Class<?>, java.lang.Object> ignored on [EnhancedAnnotatedTypeImpl] public @ApplicationScoped <a class="mention" href="/u/named">@Named</a> class br.com.caelum.vraptor.view.LinkToHandler

20:27:08,817 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool  106) WFLYUT0021: Registered web context: /controleestoque

20:27:08,877 INFO  [org.jboss.as.server] (ServerService Thread Pool  34) WFLYSRV0010: Deployed “ControleEstoque-0.0.1-SNAPSHOT.war” (runtime-name : “ControleEstoque-0.0.1-SNAPSHOT.war”)

20:27:09,119 INFO  [<a href="http://org.jboss.as">org.jboss.as</a>] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on <a href="http://127.0.0.1:9990/management">http://127.0.0.1:9990/management</a>

20:27:09,120 INFO  [<a href="http://org.jboss.as">org.jboss.as</a>] (Controller Boot Thread) WFLYSRV0051: Admin console listening on <a href="http://127.0.0.1:9990">http://127.0.0.1:9990</a>

20:27:09,129 INFO  [<a href="http://org.jboss.as">org.jboss.as</a>] (Controller Boot Thread) WFLYSRV0025: WildFly Full 10.1.0.Final (WildFly Core 2.2.0.Final) started in 9978ms - Started 817 of 1066 services (406 services are lazy, passive or on-demand)

Mas quando tento acessar qualquer controller é apresentado o debug abaixo

20:30:23,317 INFO [DefaultConverters ] Registering bundled converters
20:30:23,331 INFO [DefaultConverters ] Registering bundled converters
20:30:23,333 DEBUG [DefaultConverters ] Unable to find a converter for class java.time.LocalTime. Returning NullConverter.
20:30:23,334 DEBUG [DefaultConverters ] adding converter class br.com.caelum.vraptor.converter.LocalTimeConverter to class java.time.LocalTime
20:30:23,334 DEBUG [DefaultConverters ] Unable to find a converter for class java.lang.Integer. Returning NullConverter.
20:30:23,334 DEBUG [DefaultConverters ] adding converter class br.com.caelum.vraptor.converter.IntegerConverter to class java.lang.Integer
20:30:23,334 DEBUG [DefaultConverters ] Unable to find a converter for class java.lang.Long. Returning NullConverter.
20:30:23,335 DEBUG [DefaultConverters ] adding converter class br.com.caelum.vraptor.converter.LongConverter to class java.lang.Long
20:30:23,335 DEBUG [DefaultConverters ] Unable to find a converter for class java.util.Calendar. Returning NullConverter.
20:30:23,335 DEBUG [DefaultConverters ] adding converter class br.com.caelum.vraptor.converter.CalendarConverter to class java.util.Calendar
20:30:23,335 DEBUG [DefaultConverters ] Unable to find a converter for int. Returning NullConverter.
20:30:23,335 DEBUG [DefaultConverters ] adding converter class br.com.caelum.vraptor.converter.PrimitiveIntConverter to int
20:30:23,336 DEBUG [DefaultConverters ] Unable to find a converter for long. Returning NullConverter.
20:30:23,336 DEBUG [DefaultConverters ] adding converter class br.com.caelum.vraptor.converter.PrimitiveLongConverter to long
20:30:23,336 DEBUG [DefaultConverters ] Unable to find a converter for float. Returning NullConverter.
20:30:23,336 DEBUG [DefaultConverters ] adding converter class br.com.caelum.vraptor.converter.PrimitiveFloatConverter to float
20:30:23,337 DEBUG [DefaultConverters ] Unable to find a converter for class java.math.BigDecimal. Returning NullConverter.
20:30:23,337 DEBUG [DefaultConverters ] adding converter class br.com.caelum.vraptor.converter.BigDecimalConverter to class java.math.BigDecimal
20:30:23,337 DEBUG [DefaultConverters ] Unable to find a converter for char. Returning NullConverter.
20:30:23,337 DEBUG [DefaultConverters ] adding converter class br.com.caelum.vraptor.converter.PrimitiveCharConverter to char
20:30:23,337 DEBUG [DefaultConverters ] Unable to find a converter for double. Returning NullConverter.
20:30:23,337 DEBUG [DefaultConverters ] adding converter class br.com.caelum.vraptor.converter.PrimitiveDoubleConverter to double
20:30:23,338 DEBUG [DefaultConverters ] Unable to find a converter for boolean. Returning NullConverter.
20:30:23,338 DEBUG [DefaultConverters ] adding converter class br.com.caelum.vraptor.converter.PrimitiveBooleanConverter to boolean
20:30:23,342 DEBUG [DefaultConverters ] Unable to find a converter for class java.lang.Boolean. Returning NullConverter.
20:30:23,342 DEBUG [DefaultConverters ] adding converter class br.com.caelum.vraptor.converter.BooleanConverter to class java.lang.Boolean
20:30:23,343 DEBUG [DefaultConverters ] Unable to find a converter for byte. Returning NullConverter.
20:30:23,347 DEBUG [DefaultConverters ] adding converter class br.com.caelum.vraptor.converter.PrimitiveByteConverter to byte
20:30:23,347 DEBUG [DefaultConverters ] Unable to find a converter for class java.math.BigInteger. Returning NullConverter.
20:30:23,347 DEBUG [DefaultConverters ] adding converter class br.com.caelum.vraptor.converter.BigIntegerConverter to class java.math.BigInteger
20:30:23,348 DEBUG [DefaultConverters ] Unable to find a converter for class java.lang.Byte. Returning NullConverter.
20:30:23,348 DEBUG [DefaultConverters ] adding converter class br.com.caelum.vraptor.converter.ByteConverter to class java.lang.Byte
20:30:23,350 DEBUG [DefaultConverters ] Unable to find a converter for class java.lang.Enum. Returning NullConverter.
20:30:23,350 DEBUG [DefaultConverters ] adding converter class br.com.caelum.vraptor.converter.EnumConverter to class java.lang.Enum
20:30:23,351 DEBUG [DefaultConverters ] Unable to find a converter for class java.lang.String. Returning NullConverter.
20:30:23,351 DEBUG [DefaultConverters ] adding converter class br.com.caelum.vraptor.converter.StringConverter to class java.lang.String
20:30:23,351 DEBUG [DefaultConverters ] Unable to find a converter for class java.lang.Short. Returning NullConverter.
20:30:23,351 DEBUG [DefaultConverters ] adding converter class br.com.caelum.vraptor.converter.ShortConverter to class java.lang.Short
20:30:23,370 DEBUG [InterceptorStereotypeHandler] Found interceptor for class br.com.caelum.vraptor.interceptor.FlashInterceptor
20:30:23,371 DEBUG [DefaultConverters ] Unable to find a converter for class java.time.LocalDateTime. Returning NullConverter.
20:30:23,372 DEBUG [DefaultConverters ] adding converter class br.com.caelum.vraptor.converter.LocalDateTimeConverter to class java.time.LocalDateTime
20:30:23,372 DEBUG [DefaultConverters ] Unable to find a converter for short. Returning NullConverter.
20:30:23,372 DEBUG [DefaultConverters ] adding converter class br.com.caelum.vraptor.converter.PrimitiveShortConverter to short
20:30:23,373 DEBUG [DefaultConverters ] Unable to find a converter for class java.lang.Double. Returning NullConverter.
20:30:23,374 DEBUG [DefaultConverters ] adding converter class br.com.caelum.vraptor.converter.DoubleConverter to class java.lang.Double
20:30:23,375 DEBUG [DefaultConverters ] Unable to find a converter for class java.lang.Character. Returning NullConverter.
20:30:23,375 DEBUG [DefaultConverters ] adding converter class br.com.caelum.vraptor.converter.CharacterConverter to class java.lang.Character
20:30:23,376 DEBUG [DefaultConverters ] Unable to find a converter for class java.util.Date. Returning NullConverter.
20:30:23,376 DEBUG [DefaultConverters ] adding converter class br.com.caelum.vraptor.converter.DateConverter to class java.util.Date
20:30:23,376 DEBUG [DefaultConverters ] Unable to find a converter for interface br.com.caelum.vraptor.observer.upload.UploadedFile. Returning NullConverter.
20:30:23,377 DEBUG [DefaultConverters ] adding converter class br.com.caelum.vraptor.observer.upload.UploadedFileConverter to interface br.com.caelum.vraptor.observer.upload.UploadedFile
20:30:23,377 DEBUG [DefaultConverters ] Unable to find a converter for class java.lang.Float. Returning NullConverter.
20:30:23,377 DEBUG [DefaultConverters ] adding converter class br.com.caelum.vraptor.converter.FloatConverter to class java.lang.Float
20:30:23,378 DEBUG [DefaultConverters ] Unable to find a converter for class java.time.LocalDate. Returning NullConverter.
20:30:23,378 DEBUG [DefaultConverters ] adding converter class br.com.caelum.vraptor.converter.LocalDateConverter to class java.time.LocalDate
20:30:23,378 DEBUG [InterceptorStereotypeHandler] Found interceptor for class br.com.caelum.vraptor.interceptor.ExceptionHandlerInterceptor
20:30:23,407 DEBUG [InterceptorStackHandlersCache] Caching br.com.caelum.vraptor.interceptor.FlashInterceptor
20:30:23,417 DEBUG [InterceptorStackHandlersCache] Caching br.com.caelum.vraptor.interceptor.ExceptionHandlerInterceptor
20:30:23,417 INFO [VRaptor ] VRaptor 4.2.0-RC3 successfuly initialized
20:30:23,464 DEBUG [DefaultControllerTranslator] trying to access /
20:30:23,484 DEBUG [VRaptor ] VRaptor ended the request

A

Pessoal, demorou mas vim postar a solução, troquei a versão do meu eclipse para a Oxygen e importei o blank-project e simplesmente funcionou.

Criado 8 de novembro de 2016
Ultima resposta 7 de dez. de 2016
Respostas 3
Participantes 2