2 Replies Latest reply on Dec 12, 2013 10:47 AM by Charles Odili

    Errai jax-rs Caller Is Null from @PageShown Method

    Charles Odili Apprentice

      I was hoping to fetch the data associated to a @Template @Page when it gets shown. However, reference to an injected Errai jax-rs Caller endpoint from within a @PageShown method in the  @Template @Page causes a null-pointer--exception. Is this the right / default behaviour ?

           @Inject
           private Caller<PutmeEndpoint> endpoint;
           ...
      
           @PageShown
           private void onPageShown() {
             ...
             fetchData(false);          // NullPointerException if called from here? works if called from @PostConstruct method
           }
      
           @PostConstruct
           private void run(){
                // this works but we load data that may never be used!
              //fetchData(false); 
           }
      
           private void fetchBundles(boolean forceFetch){
                ...
                endpoint.call(...).fetchTheData();   
           }
      
        • 1. Re: Errai jax-rs Caller Is Null from @PageShown Method
          Max Barkley Expert

          Hi Charles,

           

          This is definitely not the expected behaviour. But I can't reproduce the problem with our tutorial. Can you post the stack trace? Or maybe try adding some assert statements to figure out wha is causing the NullPointer?

           

          Cheers.

          • 2. Re: Re: Errai jax-rs Caller Is Null from @PageShown Method
            Charles Odili Apprentice

            The error is logged twice in the GWT dev-mode window and it is as follows :

            00:10:47.497 [ERROR] Uncaught exception escaped  
            com.google.gwt.event.shared.UmbrellaException: Exception caught: null
                 at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:129)
                 at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:129)
                 at com.google.gwt.event.dom.client.DomEvent.fireNativeEvent(DomEvent.java:116)
                 at com.google.gwt.user.client.ui.Widget.onBrowserEvent(Widget.java:177)
                 at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1351)
                 at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1307)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                 at java.lang.reflect.Method.invoke(Method.java:606)
                 at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
                 at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
                 at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
                 at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
                 at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
                 at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
                 at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
                 at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
                 at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
                 at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
                 at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:242)
                 at sun.reflect.GeneratedMethodAccessor146.invoke(Unknown Source)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                 at java.lang.reflect.Method.invoke(Method.java:606)
                 at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
                 at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
                 at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
                 at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
                 at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
                 at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
                 at java.lang.Thread.run(Thread.java:744)
            Caused by: java.lang.NullPointerException: null
                 at org.jboss.errai.demo.client.local.PutmeSubjectBundles.fetchBundles(PutmeSubjectBundles.java:119)
                 at org.jboss.errai.demo.client.local.PutmeSubjectBundles.onPageShown(PutmeSubjectBundles.java:72)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                 at java.lang.reflect.Method.invoke(Method.java:606)
                 at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
                 at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
                 at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
                 at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
                 at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
                 at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
                 at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
                 at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:299)
                 at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
                 at org.jboss.errai.ui.nav.client.local.spi.GeneratedNavigationGraph$5._1585200975_onPageShown(GeneratedNavigationGraph.java)
                 at org.jboss.errai.ui.nav.client.local.spi.GeneratedNavigationGraph$5.pageShown(GeneratedNavigationGraph.java:223)
                 at org.jboss.errai.ui.nav.client.local.spi.GeneratedNavigationGraph$5.pageShown(GeneratedNavigationGraph.java:1)
                 at org.jboss.errai.ui.nav.client.local.Navigation$3.callback(Navigation.java:276)
                 at org.jboss.errai.ui.nav.client.local.Navigation$3.callback(Navigation.java:1)
                 at org.jboss.errai.ioc.client.container.SyncToAsyncBeanManagerAdpater$1.getInstance(SyncToAsyncBeanManagerAdpater.java:148)
                 at org.jboss.errai.ui.nav.client.local.spi.GeneratedNavigationGraph$5.produceContent(GeneratedNavigationGraph.java:193)
                 at org.jboss.errai.ui.nav.client.local.Navigation.showPage(Navigation.java:265)
                 at org.jboss.errai.ui.nav.client.local.Navigation.navigate(Navigation.java:207)
                 at org.jboss.errai.ui.nav.client.local.Navigation.navigate(Navigation.java:182)
                 at org.jboss.errai.ui.nav.client.local.Navigation.goTo(Navigation.java:142)
                 at org.jboss.errai.ui.nav.client.local.TransitionAnchor.onClick(TransitionAnchor.java:100)
                 at com.google.gwt.event.dom.client.ClickEvent.dispatch(ClickEvent.java:56)
                 at com.google.gwt.event.dom.client.ClickEvent.dispatch(ClickEvent.java:1)
                 at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)
                 at com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40)
                 at com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193)
                 at com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88)
                 at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:127)
                 at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:129)
                 at com.google.gwt.event.dom.client.DomEvent.fireNativeEvent(DomEvent.java:116)
                 at com.google.gwt.user.client.ui.Widget.onBrowserEvent(Widget.java:177)
                 at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1351)
                 at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1307)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                 at java.lang.reflect.Method.invoke(Method.java:606)
                 at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
                 at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
                 at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
                 at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
                 at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
                 at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
                 at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
                 at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
                 at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
                 at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
                 at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:242)
                 at sun.reflect.GeneratedMethodAccessor146.invoke(Unknown Source)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                 at java.lang.reflect.Method.invoke(Method.java:606)
                 at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
                 at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
                 at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
                 at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
                 at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
                 at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
                 at java.lang.Thread.run(Thread.java:744)