4 Replies Latest reply on Jan 21, 2012 7:53 PM by Michael McGovern

    Support for EJB as REST resource in 7.1.0

    Michael McGovern Newbie

      Hi,

       

      I'd like to use a SLSB as the REST resource - which I'm sure I had working in AS 6.0.0

       

      Some doco I've seen talks about subclassing Application - but I want CMT.

       

      Also some RestEasy doco I saw was talking about annotating the Local and adding entries in web.xml.

       

      Can someone clarify the best/easiest way to get CMT with resources in AS 7.1.0?

       

      Thanks,

       

      Michael

        • 1. Re: Support for EJB as REST resource in 7.1.0
          Michael McGovern Newbie

          OK,

           

          Should I even by trying to use EJBs or should I use sub class of application/POJO resources and manually lookup EJBs for further processing and let the CMT happen there?

          • 2. Re: Support for EJB as REST resource in 7.1.0
            jaikiran pai Master

            I am not sure I understand. Could you post some relevant code which will help explain what you are trying?

            • 3. Re: Support for EJB as REST resource in 7.1.0
              Michael McGovern Newbie

              Thanks Jaikiran -

               

               

              In AS 6.0.0 I had a SLSB that was a REST resource.....

               

               

               

               

               

               

               

               

               

               

               

               

               

               

              @Path

              ("/system")

               

              @Stateless

              (name = "systemRest")

              @TransactionManagement

              (TransactionManagementType.CONTAINER)

               

              public

               

               

               

               

               

               

               

               

               

               

              class SystemRestBean extends BaseRestBean implements SystemRest {

               

               

               

               

              @GET

               

               

               

               

              @Path("/status")

               

               

               

              @Produces("application/xml")

               

               

               

              @Override

               

               

               

               

              public SystemStatusCheck systemStatus() {

               

               

              ....

               

               

               

              This code doesn't work under AS 7, I get an error about it trying to lookup the resource and failing....

               

               

               

               

               

              21:28:52,338 WARN [org.jboss.resteasy.core.SynchronousDispatcher] (http-127.0.0.1-127.0.0.1-80-1) Unknown exception while executing GET system/status:

              java.lang.RuntimeException: javax.naming.NameNotFoundException

              : rest/SystemRestBean!com.vantage.capital.service.rest.system.SystemRestBean -- service jboss.naming.context.java.app.Capital.rest."SystemRestBean!com.vantage.capital.service.rest.system.SystemRestBean"

              at org.jboss.resteasy.plugins.server.resourcefactory.JndiComponentResourceFactory.createResource(

              JndiComponentResourceFactory.java:57

              ) [resteasy-jaxrs-2.3.0.GA.jar:]

              at org.jboss.resteasy.core.ResourceMethod.invoke(

              ResourceMethod.java:210

              ) [resteasy-jaxrs-2.3.0.GA.jar:]

               

               

               

               

              I'm fairly sure it worked in AS 6.

               

               

               

               

               

              The documentation I read (AS 7 Dev for JAX-RS) only talks about using subclass of Application - I assume this doesn''t mean resources as SLSB (or does it)?

               

               

               

              So the fundamental question is: Can a SLSB be used as a REST resource? If so, how exactly in AS 7?

               

              and if not. what are the options for integration with other EJBs doing CMT processing?

               

              The REST resources are a thin layer over other SLSB that process transactions for a banking system so I was thinking of the POJO resource approach and lookup the SLSB to do the actual processing.

              Hope this makes sense.

              • 4. Re: Support for EJB as REST resource in 7.1.0
                Michael McGovern Newbie

                I've found the issue.

                 

                I had @Stateless(name = "systemRest") -  a name different to the class name  (SystemRestBean)- which is why the JNDI lookup failed. (javax.naming.NameNotFoundException

                : rest/SystemRestBean!com.vantage.capital.service.rest.system.SystemRestBean)

                 

                 

                 

                Once I removed the name attribute (and also being EJB 3.1 got rid of the separate interface) it now works.

                 

                Thanks