Estou enfrentando um problema quando o sistema é carregado. O servidor retorna uma exceção na chamada do método lista() do controller HoraLancada. Eu cheguei a retirar esse método do menu então o sistema funciona normal. quando cadastro uma hora no sistema, funciona normalmente inclusive o dado é persistido no bando de dados, então quando é redirecionado para a lista de horas cadastradas acontece novamente o erro. segue abaixo o erro e minha classe do controller.
{Controller} HoraLancada
package br.com.alura.horas.controller;
import br.com.alura.horas.dao.HoraLancadaDao;
import br.com.alura.horas.modelo.HoraLancada;
import br.com.alura.horas.seguranca.UsuarioLogado;
import br.com.caelum.vraptor.Controller;
import br.com.caelum.vraptor.Path;
import br.com.caelum.vraptor.Post;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.interceptor.IncludeParameters;
import br.com.caelum.vraptor.validator.Validator;
import javax.inject.Inject;
import javax.validation.Valid;
@Controller
public class HoraLancadaController {
private final HoraLancadaDao horaLancadaDao;
private final Validator validator;
private final Result result;
private final UsuarioLogado usuarioLogado;
@Inject
public HoraLancadaController(HoraLancadaDao horaLancadaDao, Validator validator, Result result, UsuarioLogado usuarioLogado){
this.horaLancadaDao = horaLancadaDao;
this.validator = validator;
this.result = result;
this.usuarioLogado = usuarioLogado;
}
public HoraLancadaController(){
this(null,null,null,null);
}
@Path("/horaLacada/form")
public void form(){
}
@IncludeParameters
@Post
public void adiciona(@Valid HoraLancada horaLancada){
validator.onErrorRedirectTo(this).form();
horaLancada.setUsuario(usuarioLogado.getUsuario());
horaLancadaDao.adiciona(horaLancada);
result.redirectTo(this).lista();
}
private void lista() {
Result include = result.include("horas", horaLancadaDao.lista());
}
}
{DAO} HoraLancada
package br.com.alura.horas.dao;
import br.com.alura.horas.modelo.HoraLancada;
import java.util.List;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
@RequestScoped
public class HoraLancadaDao {
private final EntityManager manager;
@Inject
public HoraLancadaDao(EntityManager manager){
this.manager = manager;
}
public HoraLancadaDao(){
this(null);
}
public void adiciona(HoraLancada horaLancada) {
manager.getTransaction().begin();
manager.persist(horaLancada);
manager.getTransaction().commit();
}
public void busca(HoraLancada horaLancada) {
manager.find(HoraLancada.class, horaLancada.getId());
}
@SuppressWarnings("unchecked")
public List<HoraLancada> lista(){
String jpql = "select h from HoraLancada h";
TypedQuery<HoraLancada> query = manager.createQuery(jpql, HoraLancada.class);
return query.getResultList();
}
}
{Erro}
HTTP Status 500 - /WEB-INF/jsp/login/form.jsp raised an exception
type Exception report
message /WEB-INF/jsp/login/form.jsp raised an exception
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: /WEB-INF/jsp/login/form.jsp raised an exception
br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:127)
root cause
org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: javax.el.ELException: br.com.caelum.vraptor.http.route.RouteNotFoundException: The selected route is invalid for redirection: class br.com.alura.horas.controller.HoraLancadaController.lista
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:591)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:461)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
br.com.caelum.vraptor.core.DefaultStaticContentHandler.deferProcessingToContainer(DefaultStaticContentHandler.java:87)
br.com.caelum.vraptor.core.DefaultStaticContentHandler$Proxy$_$$_WeldClientProxy.deferProcessingToContainer(Unknown Source)
br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:114)
br.com.caelum.vraptor.view.DefaultPageResult.defaultView(DefaultPageResult.java:81)
br.com.caelum.vraptor.observer.ForwardToDefaultView.forward(ForwardToDefaultView.java:67)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:497)
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.observer.RequestHandlerObserver.handle(RequestHandlerObserver.java:94)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:497)
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:123)
root cause
javax.servlet.ServletException: javax.servlet.jsp.JspException: javax.el.ELException: br.com.caelum.vraptor.http.route.RouteNotFoundException: The selected route is invalid for redirection: class br.com.alura.horas.controller.HoraLancadaController.lista
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:905)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:838)
org.apache.jsp.WEB_002dINF.jsp.login.form_jsp._jspService(form_jsp.java:154)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
br.com.caelum.vraptor.core.DefaultStaticContentHandler.deferProcessingToContainer(DefaultStaticContentHandler.java:87)
br.com.caelum.vraptor.core.DefaultStaticContentHandler$Proxy$_$$_WeldClientProxy.deferProcessingToContainer(Unknown Source)
br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:114)
br.com.caelum.vraptor.view.DefaultPageResult.defaultView(DefaultPageResult.java:81)
br.com.caelum.vraptor.observer.ForwardToDefaultView.forward(ForwardToDefaultView.java:67)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:497)
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.observer.RequestHandlerObserver.handle(RequestHandlerObserver.java:94)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:497)
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:123)
root cause
javax.el.ELException: br.com.caelum.vraptor.http.route.RouteNotFoundException: The selected route is invalid for redirection: class br.com.alura.horas.controller.HoraLancadaController.lista
javax.el.BeanELResolver.invoke(BeanELResolver.java:171)
org.apache.jasper.el.JasperELResolver.invoke(JasperELResolver.java:147)
org.apache.el.parser.AstValue.getValue(AstValue.java:159)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:943)
org.apache.jsp.WEB_002dINF.jsp.header_jsp._jspService(header_jsp.java:169)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.taglibs.standard.tag.common.core.ImportSupport.acquireString(ImportSupport.java:314)
org.apache.taglibs.standard.tag.common.core.ImportSupport.doEndTag(ImportSupport.java:171)
org.apache.jsp.WEB_002dINF.jsp.login.form_jsp._jspx_meth_c_005fimport_005f0(form_jsp.java:175)
org.apache.jsp.WEB_002dINF.jsp.login.form_jsp._jspService(form_jsp.java:121)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
br.com.caelum.vraptor.core.DefaultStaticContentHandler.deferProcessingToContainer(DefaultStaticContentHandler.java:87)
br.com.caelum.vraptor.core.DefaultStaticContentHandler$Proxy$_$$_WeldClientProxy.deferProcessingToContainer(Unknown Source)
br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:114)
br.com.caelum.vraptor.view.DefaultPageResult.defaultView(DefaultPageResult.java:81)
br.com.caelum.vraptor.observer.ForwardToDefaultView.forward(ForwardToDefaultView.java:67)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:497)
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.observer.RequestHandlerObserver.handle(RequestHandlerObserver.java:94)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:497)
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:123)
root cause
br.com.caelum.vraptor.http.route.RouteNotFoundException: The selected route is invalid for redirection: class br.com.alura.horas.controller.HoraLancadaController.lista
br.com.caelum.vraptor.http.route.DefaultRouter$1.urlFor(DefaultRouter.java:72)
br.com.caelum.vraptor.http.route.DefaultRouter.urlFor(DefaultRouter.java:174)
br.com.caelum.vraptor.http.route.DefaultRouter$Proxy$_$$_WeldClientProxy.urlFor(Unknown Source)
br.com.caelum.vraptor.view.Linker.getLink(Linker.java:51)
br.com.caelum.vraptor.view.LinkToHandler$1.intercept(LinkToHandler.java:143)
br.com.caelum.vraptor.proxy.JavassistProxifier$MethodInvocationAdapter.invoke(JavassistProxifier.java:106)
br.com.alura.horas.controller.HoraLancadaController$linkTo$alura-horas_$$_jvst21a_3.lista(HoraLancadaController$linkTo$alura-horas_$$_jvst21a_3.java)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:497)
javax.el.BeanELResolver.invoke(BeanELResolver.java:165)
org.apache.jasper.el.JasperELResolver.invoke(JasperELResolver.java:147)
org.apache.el.parser.AstValue.getValue(AstValue.java:159)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:943)
org.apache.jsp.WEB_002dINF.jsp.header_jsp._jspService(header_jsp.java:169)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.taglibs.standard.tag.common.core.ImportSupport.acquireString(ImportSupport.java:314)
org.apache.taglibs.standard.tag.common.core.ImportSupport.doEndTag(ImportSupport.java:171)
org.apache.jsp.WEB_002dINF.jsp.login.form_jsp._jspx_meth_c_005fimport_005f0(form_jsp.java:175)
org.apache.jsp.WEB_002dINF.jsp.login.form_jsp._jspService(form_jsp.java:121)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
br.com.caelum.vraptor.core.DefaultStaticContentHandler.deferProcessingToContainer(DefaultStaticContentHandler.java:87)
br.com.caelum.vraptor.core.DefaultStaticContentHandler$Proxy$_$$_WeldClientProxy.deferProcessingToContainer(Unknown Source)
br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:114)
br.com.caelum.vraptor.view.DefaultPageResult.defaultView(DefaultPageResult.java:81)
br.com.caelum.vraptor.observer.ForwardToDefaultView.forward(ForwardToDefaultView.java:67)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:497)
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.observer.RequestHandlerObserver.handle(RequestHandlerObserver.java:94)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:497)
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:123)
note The full stack trace of the root cause is available in the Apache Tomcat/8.0.27 logs.
Apache Tomcat/8.0.27