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

Não consigo achar o problema

Estou recebendo uma exception na hora de chamar o autentica e revisei o código todo e não consigo encontra.

javax.servlet.ServletException: net.vidageek.mirror.exception.ReflectionProviderException: Could not invoke method autentica
    br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:120)
package br.com.caelum.vraptor.controller;

import br.com.caelum.vraptor.Controller;
import br.com.caelum.vraptor.Get;
import br.com.caelum.vraptor.Post;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.dao.UsuarioDao;
import br.com.caelum.vraptor.model.Usuario;
import br.com.caelum.vraptor.validator.I18nMessage;
import br.com.caelum.vraptor.validator.Validator;

@Controller
public class LoginController {

    private final UsuarioDao dao;
    private final Result result;
    private final Validator validator;
    private final UsuarioLogado usuarioLogado;


    public LoginController(UsuarioDao dao, Result result, Validator validator, UsuarioLogado usuarioLogado) {
        this.dao = dao;
        this.result = result;
        this.validator = validator;
        this.usuarioLogado = usuarioLogado;
    }



    @Deprecated
    public LoginController() {
        this(null, null, null, null);
    }


    @Get
    public void formulario( ) {    
    }

    @Post
    public void autentica(Usuario usuario) {
        if(!dao.existe(usuario)){
            validator.add(new I18nMessage("login", "login.invalido"));
            validator.onErrorUsePageOf(this).formulario();
        }
        usuarioLogado.setUsuario(usuario);
        result.redirectTo(ProdutoController.class).lista();
    }
}
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<link rel="stylesheet" type="text/css" href="../bootstrap/css/bootstrap.css">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!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>Formulário de login</title>
</head>
<body>
    <div class="conteiner">
        <form class="form-signin" action="<c:url value='/login/autentica'/>" method="post">
        <h2 class="form-signin-heading">Faça login para acessar o VRaptor-produtos</h2>

            <input type="text" class="form-control" name="usuario.nome" placeholder="Nome"/> 
            <input type="password" class="form-control" name="usuario.senha" placeholder="Senha"/>
            <button class="btn btn-lg btn-primary btn-block" type="submit">Login</button>

        </form>
        <c:if test="${not empty errors }">

            <div class="alert alert-danger">

                <c:forEach var="error" items="${errors}">

                    ${error.category } - ${error.message }<br>

                </c:forEach>

            </div>

        </c:if>
    </div>
</body>
</html>
6 respostas

Tudo bem Patrick?

Posta toda StackTrace , por favor, pra gente poder dar uma olhada?

Abraço!

net.vidageek.mirror.exception.ReflectionProviderException: Could not invoke method autentica
    net.vidageek.mirror.provider.java.PureJavaMethodReflectionProvider.invoke(PureJavaMethodReflectionProvider.java:45)
    net.vidageek.mirror.invoke.MethodHandlerByMethod.withArgs(MethodHandlerByMethod.java:54)
    br.com.caelum.vraptor.observer.ExecuteMethod.execute(ExecuteMethod.java:87)
    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.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:78)
    br.com.caelum.vraptor.interceptor.FlashInterceptor.intercept(FlashInterceptor.java:98)
    br.com.caelum.vraptor.interceptor.FlashInterceptor$Proxy$_$$_WeldClientProxy.intercept(Unknown Source)
    br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:58)
    br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:83)
    br.com.caelum.vraptor.interceptor.ExceptionHandlerInterceptor.intercept(ExceptionHandlerInterceptor.java:75)
    br.com.caelum.vraptor.interceptor.ExceptionHandlerInterceptor$Proxy$_$$_WeldClientProxy.intercept(Unknown Source)
    br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:58)
    br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:83)
    br.com.caelum.vraptor.core.DefaultInterceptorStack.start(DefaultInterceptorStack.java:93)
    br.com.caelum.vraptor.core.DefaultInterceptorStack$Proxy$_$$_WeldClientProxy.start(Unknown Source)
    br.com.caelum.vraptor.observer.RequestHandlerObserver.handle(RequestHandlerObserver.java:86)
    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:116)
solução!

Oi Patrick!

Na sua stack não aparece nenhum Cause by ou Root cause?

Abraço

eu só tinha mandado um parte agora vai o resto

java.lang.NullPointerException
    br.com.caelum.vraptor.controller.LoginController.autentica(LoginController.java:42)
    br.com.caelum.vraptor.controller.LoginController$Proxy$_$$_WeldClientProxy.autentica(Unknown Source)
    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)
    net.vidageek.mirror.provider.java.PureJavaMethodReflectionProvider.invoke(PureJavaMethodReflectionProvider.java:38)
    net.vidageek.mirror.invoke.MethodHandlerByMethod.withArgs(MethodHandlerByMethod.java:54)
    br.com.caelum.vraptor.observer.ExecuteMethod.execute(ExecuteMethod.java:87)
    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.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:78)
    br.com.caelum.vraptor.interceptor.FlashInterceptor.intercept(FlashInterceptor.java:98)
    br.com.caelum.vraptor.interceptor.FlashInterceptor$Proxy$_$$_WeldClientProxy.intercept(Unknown Source)
    br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:58)
    br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:83)
    br.com.caelum.vraptor.interceptor.ExceptionHandlerInterceptor.intercept(ExceptionHandlerInterceptor.java:75)
    br.com.caelum.vraptor.interceptor.ExceptionHandlerInterceptor$Proxy$_$$_WeldClientProxy.intercept(Unknown Source)
    br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:58)
    br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:83)
    br.com.caelum.vraptor.core.DefaultInterceptorStack.start(DefaultInterceptorStack.java:93)
    br.com.caelum.vraptor.core.DefaultInterceptorStack$Proxy$_$$_WeldClientProxy.start(Unknown Source)
    br.com.caelum.vraptor.observer.RequestHandlerObserver.handle(RequestHandlerObserver.java:86)
    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:116)

achei o problema não tinha colocado o inject no construtor e aparentemente ficou invisível pra mim.

Oi Patrick!

Eu até pensei em falar isso no começo mas me perguntei se o VRaptor tinha uma extensão para injetar as dependências automaticamente nos controllers!

Que bom que funcionou então!

Um Abraço!