[ https://issues.apache.org/jira/browse/DELTASPIKE-1135?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
John D. Ament closed DELTASPIKE-1135. ------------------------------------- > Cannot use typesafe messages on Application scope initialization observer > ------------------------------------------------------------------------- > > Key: DELTASPIKE-1135 > URL: https://issues.apache.org/jira/browse/DELTASPIKE-1135 > Project: DeltaSpike > Issue Type: Improvement > Components: Core > Affects Versions: 1.6.0 > Environment: Java 1.8.0_77-b03, Wildfly 8.2.0 > Reporter: Juan Pablo Angamarca > Assignee: Gerhard Petracek > Priority: Minor > Fix For: 1.7.0 > > > Hi. I'm running into a problem when trying to use DS' typesafe messages in a > observer method that runs upon initialization of the application scope. > Code (relevant methods only): > @Dependent > @MessageBundle > // (Messages.properties is has been set-up correctly) > public interface Messages { > String administrador(); > > } > @Dependent > public class StartupBean implements Serializable { > @Inject > private Messages msgs; > public void runOnStartup(@Observes > @Initialized(ApplicationScoped.class) ServletContext payload) { > this.log.info(this.msgs.administrador()); > } > } > When the observer method is executed, I'm being presented with this > stacktrace, and deployment of application is aborted: > 23:56:34,238 SEVERE [faces] (FactoryFinderInstance.java:177) Unable to obtain > InjectionProvider from init time FacesContext. Does this container implement > the Mojarra Injection SPI? > 23:56:34,239 SEVERE [faces] (FactoryFinderInstance.java:494) La aplicación no > se ha inicializado correctamente durante el inicio, no se encuentra la > fábrica: javax.faces.application.ApplicationFactory. Attempting to find > backup. > 23:56:34,239 ERROR [fail] (ServiceControllerImpl.java:1955) MSC000001: Failed > to start service jboss.undertow.deployment.default-server.default-host./app: > org.jboss.msc.service.StartException in service > jboss.undertow.deployment.default-server.default-host./hg: Failed to start > service > at > org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) > [jboss-msc-1.2.2.Final.jar:1.2.2.Final] > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) > [rt.jar:1.8.0_77] > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) > [rt.jar:1.8.0_77] > at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_77] > Caused by: java.lang.RuntimeException: java.lang.IllegalStateException: Could > not find backup for factory javax.faces.application.ApplicationFactory. > at > io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:222) > at > org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:87) > at > org.wildfly.extension.undertow.deployment.UndertowDeploymentService.start(UndertowDeploymentService.java:72) > at > org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) > [jboss-msc-1.2.2.Final.jar:1.2.2.Final] > at > org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) > [jboss-msc-1.2.2.Final.jar:1.2.2.Final] > ... 3 more > Caused by: java.lang.IllegalStateException: Could not find backup for factory > javax.faces.application.ApplicationFactory. > at > javax.faces.FactoryFinderInstance.getFactory(FactoryFinderInstance.java:500) > at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:287) > at > com.sun.faces.config.InitFacesContext.getApplication(InitFacesContext.java:142) > at > org.apache.deltaspike.jsf.impl.message.JsfMessageResolver.getMessageSources(JsfMessageResolver.java:45) > at > org.apache.deltaspike.core.impl.message.DefaultMessageResolver.getMessage(DefaultMessageResolver.java:52) > at > org.apache.deltaspike.core.impl.message.DefaultMessage.toString(DefaultMessage.java:115) > at > org.apache.deltaspike.core.impl.message.DefaultMessage.toString(DefaultMessage.java:95) > at > org.apache.deltaspike.core.impl.message.MessageBundleInvocationHandler.invoke(MessageBundleInvocationHandler.java:123) > at com.sun.proxy.$Proxy1079.administrador(Unknown Source) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > [rt.jar:1.8.0_77] > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > [rt.jar:1.8.0_77] > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > [rt.jar:1.8.0_77] > at java.lang.reflect.Method.invoke(Method.java:498) [rt.jar:1.8.0_77] > at > org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:38) > at > org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:100) > at > org.jboss.weld.proxies.Messages$Serializable$981322000$Proxy$_$$_WeldClientProxy.administrador(Unknown > Source) > at com.app.core.StartupBean.runOnStartup(StartupBean.java:178) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > [rt.jar:1.8.0_77] > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > [rt.jar:1.8.0_77] > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > [rt.jar:1.8.0_77] > at java.lang.reflect.Method.invoke(Method.java:498) [rt.jar:1.8.0_77] > at > org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:90) > at > org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:271) > at > org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:258) > at > org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:237) > at org.jboss.weld.event.FastEvent.fire(FastEvent.java:125) > at > org.jboss.weld.servlet.HttpContextLifecycle.contextInitialized(HttpContextLifecycle.java:132) > at > org.jboss.weld.servlet.WeldInitialListener.contextInitialized(WeldInitialListener.java:101) > at > io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:173) > at > io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:193) > ... 7 more > The stacktrace says something about a FacesContext, I thought messages > independent from JSF... Messages work normally in any other situation, even > in a RESTful endpoint: > @Path("svctest") > @RequestScoped > public class SvcTest { > @Inject > private Messages messages; > @GET > @Path("administrador") > public String run() { > /* look Mom, no FacesContext! ;) */ > return this.messages.administrador(); > } > } > Result of invocation: > GET HTTP/1.1 http://localhost:8080/app/services/svctest/administrador > Administrador > What am I doing wrong here? What can I do to run code that needs to use > typesafe messages at application startup? Thanks for your attention. -- This message was sent by Atlassian JIRA (v6.3.4#6332)