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

Using @Resource annotation with RESTEasy in JBoss 6.1.0 Final

Jack Lund Newbie

Hi,

 

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">

  <context-param>

    <param-name>resteasy.scan</param-name>

    <param-value>true</param-value>

  </context-param>

  <servlet>

    <servlet-name>DeviceAPI</servlet-name>

    <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>

  </servlet>

  <servlet-mapping>

    <servlet-name>DeviceAPI</servlet-name>

    <url-pattern>/*</url-pattern>

  </servlet-mapping>

</web-app>

 

 

And here's the code for my service:

 

 

@Path("/pw/readings/device")

public class ReadingsServiceImpl

{

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

    private ConnectionFactory connectionFactory;

   

    @Resource(mappedName="/queue/deviceAPI")

    private Queue queue;

   

    private JMSSender sender = new JMSSender();

 

    @POST

    @Path("/{deviceUID}/channel/{channelID}")

    @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.setConnectionFactory(connectionFactory);

        sender.setQueue(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?

 

Thanks

 

-Jack Lund