Error when trying to use custom template provider
magick93 Nov 26, 2015 7:29 AMHello
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; @Dependent public class DocsTemplate implements TemplateProvider { @Inject SelectedRule selectedRule; @Override 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"; } renderingCallback.renderTemplate(template); } }