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

HTTP Status 500 - The server encountered an internal error that prevented it from fulfilling this request.

Boa tarde pessoal!

Quando eu tento acessar a lista de usuários, gera o erro no browser:

HTTP Status 500 - 


type Exception report

message 

description The server encountered an internal error that prevented it from fulfilling this request.

exception
java.lang.NullPointerException
    br.com.alura.horas.controller.UsuarioController.lista(UsuarioController.java:44)
    br.com.alura.horas.controller.UsuarioController$Proxy$_$$_WeldClientProxy.lista(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.core.DefaultReflectionProvider.invoke(DefaultReflectionProvider.java:42)
    br.com.caelum.vraptor.core.DefaultReflectionProvider$Proxy$_$$_WeldClientProxy.invoke(Unknown Source)
    br.com.caelum.vraptor.observer.ExecuteMethod$1.call(ExecuteMethod.java:82)
    br.com.caelum.vraptor.observer.ExecuteMethod$1.call(ExecuteMethod.java:72)
    br.com.caelum.vraptor.core.Try.run(Try.java:18)
    br.com.caelum.vraptor.observer.ExecuteMethod.execute(ExecuteMethod.java:72)
    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$1.call(ToInstantiateInterceptorHandler.java:71)
    br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler$1.call(ToInstantiateInterceptorHandler.java:68)
    br.com.caelum.vraptor.core.Try.run(Try.java:18)
    br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.executeSafely(ToInstantiateInterceptorHandler.java:68)
    br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:61)
    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$1.call(ToInstantiateInterceptorHandler.java:71)
    br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler$1.call(ToInstantiateInterceptorHandler.java:68)
    br.com.caelum.vraptor.core.Try.run(Try.java:18)
    br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.executeSafely(ToInstantiateInterceptorHandler.java:68)
    br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:61)
    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:93)
    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:123)

 note The full stack trace of the root cause is available in the Apache Tomcat/8.5.8 logs.

--------------------------------------------------------------------------------

Apache Tomcat/8.5.8

Gera o erro no console:

jan 25, 2017 5:02:15 PM org.apache.catalina.core.StandardWrapperValve invoke
GRAVE: Servlet.service() for servlet [default] in context with path [/alura-horas] threw exception
java.lang.NullPointerException
    at br.com.alura.horas.controller.UsuarioController.lista(UsuarioController.java:44)
    at br.com.alura.horas.controller.UsuarioController$Proxy$_$$_WeldClientProxy.lista(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.vidageek.mirror.provider.java.PureJavaMethodReflectionProvider.invoke(PureJavaMethodReflectionProvider.java:38)
    at net.vidageek.mirror.invoke.MethodHandlerByMethod.withArgs(MethodHandlerByMethod.java:54)
    at br.com.caelum.vraptor.core.DefaultReflectionProvider.invoke(DefaultReflectionProvider.java:42)
    at br.com.caelum.vraptor.core.DefaultReflectionProvider$Proxy$_$$_WeldClientProxy.invoke(Unknown Source)
    at br.com.caelum.vraptor.observer.ExecuteMethod$1.call(ExecuteMethod.java:82)
    at br.com.caelum.vraptor.observer.ExecuteMethod$1.call(ExecuteMethod.java:72)
    at br.com.caelum.vraptor.core.Try.run(Try.java:18)
    at br.com.caelum.vraptor.observer.ExecuteMethod.execute(ExecuteMethod.java:72)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:93)
    at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:266)
    at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:253)
    at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:232)
    at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:169)
    at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:165)
    at org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:119)
    at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:112)
    at org.jboss.weld.event.EventImpl.fire(EventImpl.java:83)
    at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:78)
    at br.com.caelum.vraptor.interceptor.FlashInterceptor.intercept(FlashInterceptor.java:98)
    at br.com.caelum.vraptor.interceptor.FlashInterceptor$Proxy$_$$_WeldClientProxy.intercept(Unknown Source)
    at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler$1.call(ToInstantiateInterceptorHandler.java:71)
    at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler$1.call(ToInstantiateInterceptorHandler.java:68)
    at br.com.caelum.vraptor.core.Try.run(Try.java:18)
    at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.executeSafely(ToInstantiateInterceptorHandler.java:68)
    at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:61)
    at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:83)
    at br.com.caelum.vraptor.interceptor.ExceptionHandlerInterceptor.intercept(ExceptionHandlerInterceptor.java:75)
    at br.com.caelum.vraptor.interceptor.ExceptionHandlerInterceptor$Proxy$_$$_WeldClientProxy.intercept(Unknown Source)
    at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler$1.call(ToInstantiateInterceptorHandler.java:71)
    at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler$1.call(ToInstantiateInterceptorHandler.java:68)
    at br.com.caelum.vraptor.core.Try.run(Try.java:18)
    at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.executeSafely(ToInstantiateInterceptorHandler.java:68)
    at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:61)
    at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:83)
    at br.com.caelum.vraptor.core.DefaultInterceptorStack.start(DefaultInterceptorStack.java:93)
    at br.com.caelum.vraptor.core.DefaultInterceptorStack$Proxy$_$$_WeldClientProxy.start(Unknown Source)
    at br.com.caelum.vraptor.observer.RequestHandlerObserver.handle(RequestHandlerObserver.java:93)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:93)
    at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:266)
    at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:253)
    at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:232)
    at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:169)
    at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:165)
    at org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:119)
    at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:112)
    at org.jboss.weld.event.EventImpl.fire(EventImpl.java:83)
    at br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:123)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:789)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)
3 respostas

No browser/console diz que o erro está na linha 44 do UsuarioController:


43        public void lista() {
44            List<Usuario> usuarios = usuarioDao.lista();
45            result.include("usuarios", usuarios);
46        }

Meu UsuarioDao:

    public List<Usuario> lista() {
        TypedQuery<Usuario> query = manager.createQuery("Select u from Usuario u", Usuario.class);
        return query.getResultList();
    }
}
solução!

Boa tarde Ewerton, você está instanciando o usuarioDao ou recebendo por injeção em algum momento? pois esse erro significa que não dá para chamar um método (no caso lista) em um objeto null(no caso usuarioDao)

Espero ter ajudado!

Boa noite Guilherme!!

Cara era isso msm, eu esqueci de adicionar o @Inject no construtor do UsuarioController...

Muito obrigado pela ajuda!! Grande abraço!