4 Replies Latest reply on May 23, 2012 12:36 PM by Earnest Dyke

    Using @Resource annotation with RESTEasy in JBoss 6.1.0 Final

    Jack Lund Newbie



      I'm trying to set up a JMS Queue in a Restful web service in JBoss 6.1.0. Here's my web.xml:



      <?xml version="1.0" encoding="UTF-8"?>

      <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
















      And here's the code for my service:




      public class ReadingsServiceImpl


          @Resource(name="InVMConnectionFactory", mappedName="java:/ConnectionFactory")

          private ConnectionFactory connectionFactory;



          private Queue queue;


          private JMSSender sender = new JMSSender();




          @Consumes({ "application/json", "application/xml" })

          public void createReadingsForChannel(@PathParam("deviceUID") final String deviceUID,

                  @PathParam("channelID") final String channelID,

                  final Map<String, Object> data)


              System.out.println("Setting connection factory to " + connectionFactory);

              System.out.println("Setting queue to " + queue);



              sender.send(deviceUID, channelID, data);





      It seems to be attempting to map the resource, because when I don't put a mappedName in there, it gives an error. However, it never sets connectionFactory or queue here. I've looked in the JMX management console for the server, and there's definitely a connectionFactory there mapped to the JNDI name "java:/ConnectionFactory", so I'm not sure what's wrong.


      Does anybody have any insight?




      -Jack Lund