1 Reply Latest reply on Jul 9, 2011 11:02 AM by jaikiran

    Using @EJB with JBoss RESTEasy

    nikida78

      Hi folks,

      I was trying out JBoss RESTEasy on JBoss AS 6 (final), and surprisingly, it is easy to get my first RESTful web service up and running...

       

      Basically with zero configuration (no web.xml), and a simple hello class, I could get it running:

      @Path("/hello")
      public class Hello {
          @GET
          @Path("/world")
          public String getWorld() {
              return "Hello World";
          }
      }
      

       

      Next, I attempt to inject an EJB by using the @EJB annotation. However, I receive a RuntimeException: javax.naming.NameNotFoundException : local not bound.

      @Path("/hello")
      public class Hello {
          @EJB WorldMessage message;
          
          @GET
          @Path("/world")
          public String getWorld() {
              return message.getHelloMessage();
          }
      }
      

      Using the usual lookup method got it working though.

       

      I tested the same EJB with a servlet in the same web app, and it worked without a prob.

      Anyone knows why it couldn't work with the @EJB annotation?

       

      Thanks in advance.

       

      PS: I posted this in another forum with no satisfactory answer, hence I'm trying my luck here