0 Replies Latest reply on Apr 24, 2018 4:25 AM by Mylos Kathos

    Unable to Inject Temporary JMS Destinations in WildFly 12

    Mylos Kathos Master

      Hi all!

      I have the following class which used to work in WildFly 10, creating a temporary JMS destination and injecting it as Resource in a CDI Bean. As you can see from the Stacktrace below in WildFly 12 this example appears to be broken:

      @Model
       
      
      @JMSConnectionFactoryDefinition(name = "java:/TempConnectionFactory", 
      className = "javax.jms.ConnectionFactory",user="jmsuser",password="Password1!")
      @JMSDestinationDefinition(name = "java:jboss/jms/queue/tempQueue", 
                                className = "javax.jms.Queue", 
                                interfaceName = "javax.jms.Queue")
      public class MessageSender {
      
          
          String message;
      
          public String getMessage() {
              return message;
          }
      
          public void setMessage(String message) {
              this.message = message;
          }
      
       
      
          @Resource(mappedName = "java:jboss/jms/queue/tempQueue")
          Queue queue;
      
          @Inject
          @JMSConnectionFactory("java:/TempConnectionFactory")
          private JMSContext context;
      
          public void sendMessage() {
              context.createProducer().send(queue, message);
              
              
              printMessage("Sent message " + message);
          }
      
          private void printMessage(String string) {
              FacesContext.getCurrentInstance().addMessage(null,
                      new FacesMessage(FacesMessage.SEVERITY_INFO, string, string));
      
          }
           
      
      }

       

      Caused by: java.lang.IllegalArgumentException: WFLYWELD0049: Error injecting resource into CDI managed bean. Can't find a resource named java:jboss/jms/queue/tempQueue defined on javax.jms.Queue com.example.MessageSender.queue
          at org.jboss.as.weld.services.bootstrap.WeldResourceInjectionServices.resolveResource(WeldResourceInjectionServices.java:239)
          at org.jboss.as.weld.services.bootstrap.WeldResourceInjectionServices$1.createResource(WeldResourceInjectionServices.java:183)
          at org.jboss.weld.injection.AbstractResourceInjection.getResourceReference(AbstractResourceInjection.java:49)
          at org.jboss.weld.injection.AbstractResourceInjection.injectResourceReference(AbstractResourceInjection.java:63)
          at org.jboss.weld.util.Beans.injectEEFields(Beans.java:308)
          at org.jboss.weld.injection.producer.ResourceInjector$1.proceed(ResourceInjector.java:68)
          at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:48)
          at org.jboss.weld.injection.producer.ResourceInjector.inject(ResourceInjector.java:71)
          at org.jboss.weld.injection.producer.BasicInjectionTarget.inject(BasicInjectionTarget.java:117)
          at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:159)
          at org.jboss.weld.contexts.AbstractContext.get(AbstractContext.java:96)
          at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100)
          at org.jboss.weld.bean.ContextualInstanceStrategy$CachingContextualInstanceStrategy.get(ContextualInstanceStrategy.java:177)
          at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)
          at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:689)
          at org.jboss.weld.module.web.el.AbstractWeldELResolver.lookup(AbstractWeldELResolver.java:107)
          at org.jboss.weld.module.web.el.AbstractWeldELResolver.getValue(AbstractWeldELResolver.java:90)
          at org.jboss.as.jsf.injection.weld.ForwardingELResolver.getValue(ForwardingELResolver.java:46)
          at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:188)
          at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
          at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
          at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:116)
          at com.sun.el.parser.AstValue.getBase(AstValue.java:150)
          at com.sun.el.parser.AstValue.getValue(AstValue.java:199)
          at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:226)
          at org.jboss.weld.module.web.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
          at org.jboss.weld.module.web.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
          at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
          at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
          at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
          at javax.faces.component.UIOutput.getValue(UIOutput.java:174)
          at javax.faces.component.UIInput.getValue(UIInput.java:293)
          at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
          at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355)
          at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
          at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:920)
          at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
          at javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
          at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:890)
          at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
          at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
          at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
          at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:458)
          at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:134)
          at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
          at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
          at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
          at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
          at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
          at javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
          ... 41 more
      Caused by: javax.naming.NameNotFoundException: jms/queue/tempQueue -- service jboss.naming.context.java.jboss.jms.queue.tempQueue
          at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:106)

       

      Is there anything broken/changed in WildFly 12 when using Temporary Destinations?

      Thanks