2 Replies Latest reply on Jun 28, 2013 5:46 PM by Tomaz Cerar

    Unable to inject(through CDI) JMSContext

    KVMKrishna Reddy Newbie

      Hi,

       

      I am trying to inject JMSContext(JMS 2.0 API) through CDI(into either servlet or stateless session bean) and testing in wildfly 8.0.0 Alpha2 standalone(full) node. Find the below code snippet for the stateless bean which is  trying to inject JMSContext.

       

      @Local(value=IJMSSender.class)
      @Stateless(name="simplifiedJMSCDISender")
      public class SimplifiedJMSCDISender implements IJMSSender {
          @Inject 
          private JMSContext context;
          
          @Resource(lookup = "java:global/jms/demoQueue")
          Queue inboundQueue;
       public void sendMessage(String body) {
              try {
                  context.createProducer().send(inboundQueue, body);
              } catch (JMSRuntimeException ex){
                  Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
              }
          }
      }
      

       

      When I try to deploy the application(as war), I am getting deployment exceptions for injection. Find the below stack trace for the error logs.

       

      org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [JMSContext] with qualifiers [@Default] at injection point [[BackedAnnotatedField] @Inject private org.os.javaee.demo.jms.sender.SimplifiedJMSCDISender.context]
       at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:404)
       at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:326)
       at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:177)
       at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:208)
       at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:520)
       at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:70)
       at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:68)
       at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:60)
       at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:53)
       at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
       at java.util.concurrent.FutureTask.run(FutureTask.java:166)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
       at java.lang.Thread.run(Thread.java:722)
      

       

      Note: The same code is workign good in GlassFish 4.x.

       

      Thanks and Regards

      Murali Reddy