7 Replies Latest reply on Jan 21, 2012 7:55 PM by mick_mcgovern1

    Using Stateless beans with JAX-RS in AS7

    mick_mcgovern1

      Hi,

       

      Porting an app from AS6 that includes a war containing rest services as stateless bean (rest.war) inside an ear (Capital.ear).

       

      Worked under AS6 but AS7 complains with the following when the service receives a request:

       

      22:28:00,299 WARN  [org.jboss.resteasy.core.SynchronousDispatcher] (http--127.0.0.1-80-2) Unknown exception while executing POST user/logon: java.lang.RuntimeException: javax.naming.NameNotFoundException: Name 'UserLogonRestBean!com.vantage.capital.service.rest.user.UserLogonRestBean' not found in context 'rest'

      at org.jboss.resteasy.plugins.server.resourcefactory.JndiComponentResourceFactory.createResource(JndiComponentResourceFactory.java:57) [resteasy-jaxrs-2.2.1.GA.jar:]

      at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:208) [resteasy-jaxrs-2.2.1.GA.jar:]

      at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:519) [resteasy-jaxrs-2.2.1.GA.jar:]

      at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496) [resteasy-jaxrs-2.2.1.GA.jar:]

      at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119) [resteasy-jaxrs-2.2.1.GA.jar:]

      at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) [resteasy-jaxrs-2.2.1.GA.jar:]

      at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) [resteasy-jaxrs-2.2.1.GA.jar:]

      at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) [resteasy-jaxrs-2.2.1.GA.jar:]

      at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]

      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

      at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57) [jboss-as-web-7.0.0.Final.jar:7.0.0.Final]

      at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:49) [jboss-as-jpa-7.0.0.Final.jar:7.0.0.Final]

      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

      at java.lang.Thread.run(Thread.java:619) [:1.6.0_21]

      Caused by: javax.naming.NameNotFoundException: Name 'UserLogonRestBean!com.vantage.capital.service.rest.user.UserLogonRestBean' not found in context 'rest'

      at org.jboss.as.naming.util.NamingUtils.nameNotFoundException(NamingUtils.java:109)

      at org.jboss.as.naming.InMemoryNamingStore$NodeTraversingVisitor.visit(InMemoryNamingStore.java:368)

      at org.jboss.as.naming.InMemoryNamingStore$ContextNode.accept(InMemoryNamingStore.java:307)

      at org.jboss.as.naming.InMemoryNamingStore$NodeTraversingVisitor.visit(InMemoryNamingStore.java:371)

      at org.jboss.as.naming.InMemoryNamingStore$ContextNode.accept(InMemoryNamingStore.java:307)

      at org.jboss.as.naming.InMemoryNamingStore.lookup(InMemoryNamingStore.java:162)

      at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:173)

      at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:176)

      at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:207)

      at javax.naming.InitialContext.lookup(InitialContext.java:392) [:1.6.0_21]

      at org.jboss.resteasy.plugins.server.resourcefactory.JndiComponentResourceFactory.createResource(JndiComponentResourceFactory.java:53) [resteasy-jaxrs-2.2.1.GA.jar:]

      ... 22 more

       

       

      The only change I have made so far for the port for JAX-RS is the addition of a servlet mapping in web.xml.

       

      Is there something else I need to do to make SLSB available in the rest WAR? The bean it can't find is the right one for the request coming in so it seems strange.

       

       

       

      Thanks

       

      Michael

        • 1. Re: Using Stateless beans with JAX-RS in AS7
          prasad.deshpande

          As7 is strict on EE6 naming standards. This seems to me problem with jndi naming & lookup. With what name your bean is bound & How are you doing lookup?

          • 2. Re: Using Stateless beans with JAX-RS in AS7
            mick_mcgovern1

            Thats the thing - the bean is not bound explicity. The bean it can't find is the bean that handles requests for the URL. So JBoss knows what bean should handle the URL but can't find it?!?

            Here is a snip of code:

             

             

             

            @Path("/user")

            @Stateless(name = "userLogon")

             

             

             

            @TransactionManagement(TransactionManagementType.CONTAINER)

             

            class UserLogonRestBean extends BaseRestBean implements UserLogonRest {

             

            @Path("/logon")

            @Consumes("application/xml")

            @Produces("application/xml")

            public BasicRestTranResponse logon(UserLogon logon) {

            So this is the bean it can't find yet the request coming in is a URL that this bean should be handling!

            22:28:00,299 WARN [org.jboss.resteasy.core.SynchronousDispatcher] (http--127.0.0.1-80-2) Unknown exception while executing POST user/logon: java.lang.RuntimeException: javax.naming.NameNotFoundException: Name 'UserLogonRestBean!com.vantage.capital.service.rest.user.UserLogonRestBean' not found in context 'rest'

             

             

             

             

             

             

             

             

             

             

             

             

             

            • 3. Re: Using Stateless beans with JAX-RS in AS7
              jaikiran

              Michael McGovern wrote:

               

              @Stateless(name = "userLogon")

              Try removing the name attribute from it. Just let it be @Stateless and see if it works.

              • 4. Re: Using Stateless beans with JAX-RS in AS7
                mick_mcgovern1

                Thanks for idea but this did not change the result.

                • 5. Re: Using Stateless beans with JAX-RS in AS7
                  mick_mcgovern1

                  Any other thoughts on what the issue might be - thanks.

                  • 6. Re: Using Stateless beans with JAX-RS in AS7
                    blueshirts

                    "Try removing the name attribute from it. Just let it be @Stateless and see if it works."

                     

                    I know this is an old post though I had this same error message and this solved my issue.  The JNDI lookup is not using the "name" from the Session annotation.  Not sure how to fix this completely though removing the "name" portion of the Stateless annotation fixed the issue for me.

                     

                    @Stateless(name = "userLogon")

                     

                    The error from above uses a different name than is declared in the bean.

                     

                    Caused by: javax.naming.NameNotFoundException: Name 'UserLogonRestBean!com.vantage.capital.service.rest.user.UserLogonRestBean' not found in context 'rest'

                    • 7. Re: Using Stateless beans with JAX-RS in AS7
                      mick_mcgovern1

                      Thanks - that's it