8 Replies Latest reply on Jan 8, 2014 4:35 PM by hr.stoyanov

    Getting NPE with 2.4.3.Final widget bean wiring

    hr.stoyanov

      Hi all,

      I seem to be consistently getting NPE( see below) when trying to use Errai widgets. In my case I go a step further that what is shown in the tutorial or any of the examples: I create a list widgets/beans at the top level , then for each widget in the list, I create another list of different widgets/beans. (The errai tutorial shows only the trivial example when you create a one-level list of widgets, where each item widget is linked to "term" bean). I spent quite some time debugging the problem and it seems like Errai widget/bean instantiation/wiring logic falls apart after the first level. I suspect I am doing something wrong, but not sure what. I attached some code to demonstrate that causes the NPE issue.

       

      Thanks in advance for any help.

       

       

       

       

       

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

                      00:04:37.289 [ERROR] Async Task Execution Failed. Future executions (if any) are cancelled. 

      com.google.gwt.event.shared.UmbrellaException: Exception caught: error in bean initialization
           at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:129)
           at com.google.gwt.user.client.impl.HistoryImpl.fireEvent(HistoryImpl.java:80)
           at com.google.gwt.event.logical.shared.ValueChangeEvent.fire(ValueChangeEvent.java:43)
           at com.google.gwt.user.client.impl.HistoryImpl.fireHistoryChangedImpl(HistoryImpl.java:87)
           at com.google.gwt.user.client.History.fireCurrentHistoryState(History.java:131)
           at org.jboss.errai.ui.nav.client.local.Navigation$2.run(Navigation.java:115)
           at org.jboss.errai.common.client.api.extension.InitVotes$OneTimeRunnable.run(InitVotes.java:398)
           at org.jboss.errai.common.client.api.extension.InitVotes._runAllRunnables(InitVotes.java:370)
           at org.jboss.errai.common.client.api.extension.InitVotes._runAllRunnables(InitVotes.java:355)
           at org.jboss.errai.common.client.api.extension.InitVotes.finishInit(InitVotes.java:340)
           at org.jboss.errai.common.client.api.extension.InitVotes.access$3(InitVotes.java:335)
           at org.jboss.errai.common.client.api.extension.InitVotes$1.run(InitVotes.java:184)
           at org.jboss.errai.common.client.api.tasks.ClientTaskManager$ClientAsyncTask.run(ClientTaskManager.java:89)
           at org.jboss.errai.common.client.api.tasks.ClientTaskManager$TaskManagerTimer.run(ClientTaskManager.java:190)
           at com.google.gwt.user.client.Timer.fire(Timer.java:149)
           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.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.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.RuntimeException: error in bean initialization
           at org.jboss.errai.ioc.client.container.AbstractCreationalContext.fireAllInitCallbacks(AbstractCreationalContext.java:200)
           at org.jboss.errai.ioc.client.container.SimpleCreationalContext.finish(SimpleCreationalContext.java:177)
           at org.jboss.errai.ioc.client.container.IOCDependentBean.newInstance(IOCDependentBean.java:74)
           at org.jboss.errai.ioc.client.container.SyncToAsyncBeanManagerAdpater$1.newInstance(SyncToAsyncBeanManagerAdpater.java:159)
           at org.jboss.errai.ui.client.widget.ListWidget.init(ListWidget.java:172)
           at org.jboss.errai.ui.client.widget.ListWidget.setItems(ListWidget.java:140)
           at com.peruncs.s4g.web.gwt.client.local.test.TestPage.pageShown(TestPage.java:42)
           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$6._330629166_pageShown(GeneratedNavigationGraph.java)
           at org.jboss.errai.ui.nav.client.local.spi.GeneratedNavigationGraph$6.pageShown(GeneratedNavigationGraph.java:284)
           at org.jboss.errai.ui.nav.client.local.spi.GeneratedNavigationGraph$6.pageShown(GeneratedNavigationGraph.java:1)
           at org.jboss.errai.ui.nav.client.local.Navigation$3.callback(Navigation.java:280)
           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$6.produceContent(GeneratedNavigationGraph.java:254)
           at org.jboss.errai.ui.nav.client.local.Navigation.showPage(Navigation.java:269)
           at org.jboss.errai.ui.nav.client.local.Navigation.navigate(Navigation.java:211)
           at org.jboss.errai.ui.nav.client.local.Navigation.access$1(Navigation.java:194)
           at org.jboss.errai.ui.nav.client.local.Navigation$1.onValueChange(Navigation.java:107)
           at com.google.gwt.event.logical.shared.ValueChangeEvent.dispatch(ValueChangeEvent.java:128)
           at com.google.gwt.event.logical.shared.ValueChangeEvent.dispatch(ValueChangeEvent.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.impl.HistoryImpl.fireEvent(HistoryImpl.java:80)
           at com.google.gwt.event.logical.shared.ValueChangeEvent.fire(ValueChangeEvent.java:43)
           at com.google.gwt.user.client.impl.HistoryImpl.fireHistoryChangedImpl(HistoryImpl.java:87)
           at com.google.gwt.user.client.History.fireCurrentHistoryState(History.java:131)
           at org.jboss.errai.ui.nav.client.local.Navigation$2.run(Navigation.java:115)
           at org.jboss.errai.common.client.api.extension.InitVotes$OneTimeRunnable.run(InitVotes.java:398)
           at org.jboss.errai.common.client.api.extension.InitVotes._runAllRunnables(InitVotes.java:370)
           at org.jboss.errai.common.client.api.extension.InitVotes._runAllRunnables(InitVotes.java:355)
           at org.jboss.errai.common.client.api.extension.InitVotes.finishInit(InitVotes.java:340)
           at org.jboss.errai.common.client.api.extension.InitVotes.access$3(InitVotes.java:335)
           at org.jboss.errai.common.client.api.extension.InitVotes$1.run(InitVotes.java:184)
           at org.jboss.errai.common.client.api.tasks.ClientTaskManager$ClientAsyncTask.run(ClientTaskManager.java:89)
           at org.jboss.errai.common.client.api.tasks.ClientTaskManager$TaskManagerTimer.run(ClientTaskManager.java:190)
           at com.google.gwt.user.client.Timer.fire(Timer.java:149)
           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.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.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.common.client.api.Assert.notNull(Assert.java:56)
           at org.jboss.errai.databinding.client.BindableListWrapper.<init>(BindableListWrapper.java:44)
           at org.jboss.errai.ui.client.widget.ListWidget.setItems(ListWidget.java:134)
           at org.jboss.errai.ui.client.widget.ListWidget.setValue(ListWidget.java:236)
           at org.jboss.errai.ui.client.widget.ListWidget.setValue(ListWidget.java:230)
           at org.jboss.errai.ui.client.widget.ListWidget.setValue(ListWidget.java:1)
           at org.jboss.errai.databinding.client.BindableProxyAgent.updateWidgetsAndFireEvent(BindableProxyAgent.java:309)
           at org.jboss.errai.databinding.client.BindableProxyAgent.updateWidgetsAndFireEvent(BindableProxyAgent.java:277)
           at org.jboss.errai.databinding.client.BindableProxyAgent.ensureBoundListIsProxied(BindableProxyAgent.java:387)
           at org.jboss.errai.databinding.client.BindableProxyAgent.bind(BindableProxyAgent.java:153)
           at org.jboss.errai.databinding.client.api.DataBinder.bind(DataBinder.java:209)
           at org.jboss.errai.ioc.client.BootstrapperImpl$36$3.init(BootstrapperImpl.java:617)
           at org.jboss.errai.ioc.client.BootstrapperImpl$36$3.init(BootstrapperImpl.java:1)
           at org.jboss.errai.ioc.client.container.AbstractCreationalContext.fireAllInitCallbacks(AbstractCreationalContext.java:196)
           at org.jboss.errai.ioc.client.container.SimpleCreationalContext.finish(SimpleCreationalContext.java:177)
           at org.jboss.errai.ioc.client.container.IOCDependentBean.newInstance(IOCDependentBean.java:74)
           at org.jboss.errai.ioc.client.container.SyncToAsyncBeanManagerAdpater$1.newInstance(SyncToAsyncBeanManagerAdpater.java:159)
           at org.jboss.errai.ui.client.widget.ListWidget.init(ListWidget.java:172)
           at org.jboss.errai.ui.client.widget.ListWidget.setItems(ListWidget.java:140)
           at com.peruncs.s4g.web.gwt.client.local.test.TestPage.pageShown(TestPage.java:42)
           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$6._330629166_pageShown(GeneratedNavigationGraph.java)
           at org.jboss.errai.ui.nav.client.local.spi.GeneratedNavigationGraph$6.pageShown(GeneratedNavigationGraph.java:284)
           at org.jboss.errai.ui.nav.client.local.spi.GeneratedNavigationGraph$6.pageShown(GeneratedNavigationGraph.java:1)
           at org.jboss.errai.ui.nav.client.local.Navigation$3.callback(Navigation.java:280)
           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$6.produceContent(GeneratedNavigationGraph.java:254)
           at org.jboss.errai.ui.nav.client.local.Navigation.showPage(Navigation.java:269)
           at org.jboss.errai.ui.nav.client.local.Navigation.navigate(Navigation.java:211)
           at org.jboss.errai.ui.nav.client.local.Navigation.access$1(Navigation.java:194)
           at org.jboss.errai.ui.nav.client.local.Navigation$1.onValueChange(Navigation.java:107)
           at com.google.gwt.event.logical.shared.ValueChangeEvent.dispatch(ValueChangeEvent.java:128)
           at com.google.gwt.event.logical.shared.ValueChangeEvent.dispatch(ValueChangeEvent.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.impl.HistoryImpl.fireEvent(HistoryImpl.java:80)
           at com.google.gwt.event.logical.shared.ValueChangeEvent.fire(ValueChangeEvent.java:43)
           at com.google.gwt.user.client.impl.HistoryImpl.fireHistoryChangedImpl(HistoryImpl.java:87)
           at com.google.gwt.user.client.History.fireCurrentHistoryState(History.java:131)
           at org.jboss.errai.ui.nav.client.local.Navigation$2.run(Navigation.java:115)
           at org.jboss.errai.common.client.api.extension.InitVotes$OneTimeRunnable.run(InitVotes.java:398)
           at org.jboss.errai.common.client.api.extension.InitVotes._runAllRunnables(InitVotes.java:370)
           at org.jboss.errai.common.client.api.extension.InitVotes._runAllRunnables(InitVotes.java:355)
           at org.jboss.errai.common.client.api.extension.InitVotes.finishInit(InitVotes.java:340)
           at org.jboss.errai.common.client.api.extension.InitVotes.access$3(InitVotes.java:335)
           at org.jboss.errai.common.client.api.extension.InitVotes$1.run(InitVotes.java:184)
           at org.jboss.errai.common.client.api.tasks.ClientTaskManager$ClientAsyncTask.run(ClientTaskManager.java:89)
           at org.jboss.errai.common.client.api.tasks.ClientTaskManager$TaskManagerTimer.run(ClientTaskManager.java:190)
           at com.google.gwt.user.client.Timer.fire(Timer.java:149)
           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.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.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)
        • 1. Re: Getting NPE with 2.4.3.Final widget bean wiring
          mbarkley

          Hi Hristo,

           

          I think the NPE is happening because the list field in your parent bean is null. Maybe if you instantiate the field as an empty list you might have better luck.

           

          Cheers.

          • 2. Re: Getting NPE with 2.4.3.Final widget bean wiring
            hr.stoyanov

            Thanks Max, not sure I understand what you suggest though - the list of parent beans is not empty, it is populated at the point of the page being shown - is this the correct time to populate the list?:

             

            ------------TestPage.java-----------------

             

            @Override

                public void pageShown() {

                   

                   super.pageShown();

             

             

                   List<ChildBean> al = new LinkedList<ChildBean>();

                   List<ChildBean> bl = new LinkedList<ChildBean>();

                   List<ParentBean> pl = new LinkedList<ParentBean>();

                  

                   ParentBean a = new ParentBean("A",al);

                   ParentBean b = new ParentBean("B",bl);

                  

                   pl.add(a);

                   pl.add(b);

                  

                   ChildBean a1= new ChildBean("A1");

                   ChildBean a2= new ChildBean("A2");

                   al.add(a1);

                   al.add(a2);

               

                   content.parentBeanContainer.setItems(pl);

                  

                }

            • 3. Re: Getting NPE with 2.4.3.Final widget bean wiring
              hr.stoyanov

              Max,

              I spent quite some time debugging this showstopper, which leads me to believe that either Errai CDI (ECDI) falls apart, or I am doing something wrong. Here is the account of events as seen in my debugger:

              1. User refreshes  TestPage in browser

              2. Errai instantiates ParentBeanListWidget - default constructor and postConstruct method called. (I guess this is a part of instantiation of TestContent)

              3. Errai calls TestPage.pageShown()

              4. The model beans are created as part of TestPage.pageShown()

              5. At the end of the pageSown(), content.parentBeanContainer.setItems(pl); is invoked with fully populated hierarchy of model beans.

              6. I think Errai at this point start processing the submitted payload of model beans. It calls ParentBeanListWidget.getItemWidgetType(). I suspect a ParentBeanWidget instance is created

              7. Errai starts transferring data from bound fields:

                  -  ParentBean.getName() is called

                  -  ParentBean.getChildrenBeans() is called

              10. ChildBeanListWidget is instantiated- default constructor and postConstruct() called

              9. ParentBeanWidget.postConstruct() is called

              10. ParentBean.getChildBeans() is called

              11. NPE is thrown

              • 4. Re: Getting NPE with 2.4.3.Final widget bean wiring
                mbarkley

                Hristo,

                 

                Forget about my last comment; I misunderstood where the problem was occurring. I'm not sure what the problem is exactly (your code looks fine as far as I can tell), but I have some suggestions that might help figure out the issue:

                • Can you try making a templated page with a single databound ParentBean and see if that works? (If that doesn't work there might be an error we've missed with the ChildBeanListWidget.)
                • Can you post your BootstrapperImpl.java here? It will be in the folder .errai in the root of your project (generated when you compile).
                • 5. Re: Re: Getting NPE with 2.4.3.Final widget bean wiring
                  hr.stoyanov

                  Thanks Max, for looking into this issue ...

                   

                  1. Attached is the generated Bootstrap code.

                  2. I did the experiment you suggested - I created a test case where there is only a sinle ParentBeanWidget at the (top) page level with a list of children beans (I still need to resolve the case of "list-of-lists" for my project). Your suspicion was correct - I got the NPE again. I am attaching the newest test code - take a look at TestPageSingle.java and TestContentSingle.java

                   

                   

                  Let me know ...

                  • 6. Re: Re: Re: Getting NPE with 2.4.3.Final widget bean wiring
                    mbarkley

                    Hristo,

                     

                    So I've played around with this a little bit. I don't think you're going to be able to have nested ListWidgets in this way, since the ListWidget has different semantics than other bound properties.

                     

                    But I was able to get something working that might help you. Here is code I used to make a functional nested ListWidget.

                     

                    Here is the bottom level widget:

                    @Dependent
                    public class MyTextBox extends TextBox implements HasModel<String> {
                    
                      @Override
                      public String getModel() {
                        return getText();
                      }
                    
                      @Override
                      public void setModel(String model) {
                        setText(model);
                      }
                    
                    }
                    

                     

                    Here is the nested ListWidget (it's model is a list of strings):

                    @Dependent
                    public class MyListWidget extends ListWidget<String, MyTextBox> implements HasModel<List<String>> {
                    
                      @Override
                      protected Class<MyTextBox> getItemWidgetType() {
                        return MyTextBox.class;
                      }
                    
                      @Override
                      public List<String> getModel() {
                        return getValue();
                      }
                    
                      @Override
                      public void setModel(List<String> model) {
                        setValue(model);
                      }
                    }
                    

                     

                    And here is the page showing it all put together:

                    @Page(role = DefaultPage.class)
                    @Templated
                    public class TestPage extends Composite {
                    
                    
                      @Inject
                      @DataField
                      private ListWidget<List<String>, MyListWidget> testList;
                      
                      @PostConstruct
                      private void post() {
                        testList.getValue().add(new ArrayList<String>());
                        testList.getValue().get(0).add("hello");
                        testList.getValue().get(0).add("world");
                       
                        testList.getValue().add(new ArrayList<String>());
                        testList.getValue().get(1).add("goodbye");
                        testList.getValue().get(1).add("universe");
                        
                        // Unfortunately this is necessary to have changes to nested lists updated to screen.
                        testList.setValue(testList.getValue());
                      }
                    }
                    

                     

                    It isn't ideal, but this should get what you need done.

                     

                    Cheers.

                    • 7. Re: Getting NPE with 2.4.3.Final widget bean wiring
                      mbarkley

                      Hristo,

                       

                      I've looked at this issue again with the help of csa. I was mistaken earlier; binding a List to a ListWidget is a feature the ListWidget should support, but there was a bug in the framework that caused your sample code to fail because the List<ChildBean> field in the ParentBean class is not assigned any value in you no-argument constructor. We've just pushed a fix for this to 3.0-SNAPSHOT and 2.4.4-SNAPSHOT.

                       

                      So to use your code you can either switch to one of those versions of errai (3.0-SNAPSHOT or 2.4.4-SNAPSHOT), or you can modify the code in your ParentBean class so that the List<ChildBean> field is initialized to an empty list in the no-argument constructor.

                       

                      Cheers.

                      • 8. Re: Getting NPE with 2.4.3.Final widget bean wiring
                        hr.stoyanov

                        Thanks Max and Christian for fixing ERRAI-681. I will try it asap and let you know if the fix does not work.