1 Reply Latest reply: Nov 20, 2011 10:26 PM by Steve Button-Oracle RSS

    Resource Injection Annotation

    810106
      Hey All,

      I am experiencing an issue with the @Resource Injection annotation.

      Following is attached my code from my class. QueueConnectionFactory is null.

      Wierdly enough when I copy over this code and @Resource Injection in an MDB it works fine!

      Any ideas of why this might be.

      I am using WLS 10.3.5

      @Stateless
      public class dummysFriend implements dummysFriendRemote, dummysFriendLocal{

           @Resource(name = "ConnectionFactory-0",
           mappedName = "jms/connectionFactory",
           description = "Connection Factory for WLS")
           private QueueConnectionFactory connectionFactory;

           @Resource(name = "DistributedQueue-3",
           mappedName = "jms/provisionASDLQueue",
           description = "Queue which holds tokenized ASDL(s) for provision")
      private Queue provisionASDLQueue;

      private QueueConnection queueConnection = null;

      private QueueSession queueSession = null;

      private QueueSender queueSender = null;


      public dummysFriend() {
      // TODO Auto-generated constructor stub
      }


      @PostConstruct
      public void initialize(){
      try {
                queueConnection = connectionFactory.createQueueConnection();
                queueSession = queueConnection.createQueueSession(true,
                               Session.AUTO_ACKNOWLEDGE);
                queueSender = queueSession.createSender(provisionASDLQueue);

                MapMessage message = queueSession.createMapMessage();
           message.setString("ASDL", "123");
           message.setString("Token", "456");
           
           // Sending message to queue
           System.out.println("Sending Message");
           queueSender.send(message);
           
           // Closing connections
           queueSender.close();
           queueSession.close();
           queueConnection.close();
      } catch (JMSException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
           }
           }

      }