2 Replies Latest reply on Nov 27, 2015 8:03 AM by Anton Hughes

    Error when trying to use custom template provider

    Anton Hughes Master



      I am trying to use the custom template provider, however, when I try to inject a bean, and use that bean, I get an error in the browser.


      If I inject the bean, but do not use it - its fine.

      As soon as I do anything with the bean, even if it is in a try-catch, with null checks, I get the following error in the browser console:

      11:26:03 SEVERE [AbstractCreationalContext] error initializing bean: app.client.local.rule.editor.RuleEditorHelpTextcom_google_gwt_logging_client_ConsoleLogHandler_error__Ljava_lang_String_2V @ app-0.js:58534com_google_gwt_logging_client_ConsoleLogHandler_publish__Ljava_util_logging_LogRecord_2V @ app-0.js:58557com_google_gwt_logging_impl_LoggerImplRegular_log__Ljava_util_logging_LogRecord_2V @ app-0.js:59242com_google_gwt_logging_impl_LoggerImplRegular_log__Ljava_util_logging_Level_2Ljava_lang_String_2Ljava_lang_Throwable_2V @ app-0.js:59227java_util_logging_Logger_log__Ljava_util_logging_Level_2Ljava_lang_String_2Ljava_lang_Throwable_2V @ app-0.js:101397de_benediktmeurer_gwt_slf4j_jul_client_JULLogger_log__Ljava_util_logging_Level_2Ljava_lang_String_2Ljava_lang_Throwable_2V @ app-0.js:92192de_benediktmeurer_gwt_slf4j_jul_client_JULLogger_error__Ljava_lang_String_2Ljava_lang_Throwable_2V @ app-0.js:92177org_jboss_errai_ioc_client_container_AbstractCreationalContext_fireAllInitCallbacks__V @ app-0.js:195601org_jboss_errai_ioc_client_container_SimpleCreationalContext_finish__V @ app-0.js:196050org_jboss_errai_ioc_client_Container_bootstrapContainer__V @ app-0.js:194674org_jboss_errai_ioc_client_Container_onModuleLoad__V @ app-0.js:194700com_google_gwt_lang_app_100046DevApp_1_1EntryMethodHolder_init__V @ app-0.js:58468initializeModules @ app-0.js:469com_google_gwt_core_client_impl_Impl_apply__Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2 @ app-0.js:44330com_google_gwt_core_client_impl_Impl_entry0__Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2 @ app-0.js:44393(anonymous function) @ app-0.js:44360com_google_gwt_lang_ModuleUtils_gwtOnLoad__Lcom_google_gwt_core_client_JavaScriptObject_2Lcom_google_gwt_core_client_JavaScriptObject_2Lcom_google_gwt_core_client_JavaScriptObject_2Lcom_google_gwt_core_client_JavaScriptObject_2V @ app-0.js:482(anonymous function) @ app-0.js:220985

      app-0.js:194683 Uncaught java.lang.RuntimeException: critical error in IOC container bootstrap: java.lang.RuntimeException: error in bean initialization


      It seems that the SelectedRule bean (ApplicationScoped) is always null when used inside the template provider implementation, but at the same time, the bean is not null elsewhere.

      Also, the TemplateProvider implementation does not seem to work in SDM. Breakpoints added to this class do not get recognized (in Chrome).


      The code is very simple:

      package app.client.local.util;
      import javax.enterprise.context.Dependent;
      import javax.inject.Inject;
      import org.jboss.errai.ui.client.local.spi.TemplateProvider;
      import org.jboss.errai.ui.client.local.spi.TemplateRenderingCallback;
      import app.client.local.rule.SelectedRule;
      public class DocsTemplate implements TemplateProvider {
        @Inject SelectedRule selectedRule;
        public void provideTemplate(String location, TemplateRenderingCallback renderingCallback) {
        String template="";
            * Generate the template String.
            * Note: The location parameter is the value from the @Templated annotation.
        if (selectedRule!=null) {
        if (selectedRule.getSelected()!=null) {
        template = "<span>hello world</span>" + selectedRule.getSelected().getName() ;
        }else {
        template = "null";
        • 1. Re: Error when trying to use custom template provider
          Max Barkley Expert

          Hi Anton,


          I have an idea for why this might be the case. Is your templated bean also application scoped, or is it injected into an application scoped bean? If so, it may be the case that when the container bootstraps your templated bean is wired before SelectedRule is ready for injection. This wouldn't happen if you explicitly injected SelectedRule into your templated bean, but template providers are looked up dynamically through the bean manager at runtime.


          If this is the problem, you could try injecting a SelectedRule into your templated bean as a workaround.



          • 2. Re: Error when trying to use custom template provider
            Anton Hughes Master

            Hi Max


            Yes, I was injecting this into an ApplicationScoped bean.


            I actually did a workaround and created a custom component that pulls in the remote html. It works for now. But, I will try your suggestion.


            Thanks Max.