1 Reply Latest reply on Jul 17, 2011 3:36 AM by Guru Prashanth Thanakodi

    Rest and EJB

    Guru Prashanth Thanakodi Newbie

      I am trying to integrate EJB3.1 and rest.

      The @EJB injection is not working.

      Here is my program,

      ------------------------------------------------------------------

      Rest Layer

      ------------------------------------------------------------

      package com.emc.testrest;

      import javax.ejb.*;

      import javax.ws.rs.*;

       

      @Path("restlayer")

      @Stateless

      public class restlayer {

       

      @EJB

      private testlocal testObject;

       

      @Path("/enter")

      @GET

      public int enter()

      {

          int x =4;

          x = x+5;

          x = testObject.runtest();

          return x;

      }

         

       

      --------------------------------

      EJB

      ------------------------------

       

      package com.emc.testrest;

      import javax.ejb.*;

       

       

      @Stateless

      public class testlocalbean implements testlocal

      {

          private int inittest;

          public testlocalbean()

          {

              inittest =4;       

          }

         

          @Override

          public int runtest()

          {

              int x=1;

              x= x+ 8;

              return x;

          }

       

      }

       

       

       

      package com.emc.testrest;

       

      import javax.ejb.*;

       

      @Local

      public interface testlocal

      {

          public int runtest();   

         

      }

       

       

       

      When I deploy Jboss displays these messages

      17:17:17,375 INFO  [org.jboss.ejb3.session.SessionSpecContainer] Starting jboss.j2ee:jar=restapi.war,name=restlayer,service=EJB3

      17:17:17,375 INFO  [org.jboss.ejb3.EJBContainer] STARTED EJB: com.emc.testrest.restlayer ejbName: restlayer

      17:17:17,375 INFO  [org.jboss.ejb3.proxy.impl.jndiregistrar.JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:

       

       

      17:17:17,375 WARN  [org.jboss.ejb3.TimerServiceContainer] EJBTHREE-2193: using deprecated TimerServiceFactory for restoring timers

      17:17:17,375 INFO  [org.jboss.web.tomcat.service.deployers.TomcatDeployment] deploy, ctxPath=/restapi

      17:17:17,437 INFO  [org.jboss.ejb3.nointerface.impl.jndi.AbstractNoInterfaceViewBinder] Binding the following entry in Global JNDI for bean:restlayer

       

          restlayer/no-interface -> EJB3.1 no-interface view

       

       

       

      But when I call rest client to call this interface I get the following Exception

      Restcall:http://localhost:8080/restapi/restlayer/enter

       

      17:30:13,750 WARN  [org.jboss.resteasy.core.SynchronousDispatcher] Unknown exception while executing GET /restlayer/enter: java.lang.RuntimeException: javax.naming.NameNotFoundException: local not bound

          at org.jboss.resteasy.plugins.server.resourcefactory.JndiComponentResourceFactory.createResource(JndiComponentResourceFactory.java:57) [:6.0.0.Final]

          at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:205) [:6.0.0.Final]

          at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:503) [:6.0.0.Final]

          at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:480) [:6.0.0.Final]

          at org.jboss.resteasy.core.SynchronousDispatcher.invokePropagateNotFound(SynchronousDispatcher.java:139) [:6.0.0.Final]

          at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:211) [:6.0.0.Final]

          at org.jboss.resteasy.plugins.server.servlet.FilterDispatcher.doFilter(FilterDispatcher.java:59) [:6.0.0.Final]

          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:6.0.0.Final]

          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]

          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [:6.0.0.Final]

          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) [:6.0.0.Final]

          at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181) [:6.0.0.Final]

          at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285) [:1.1.0.Final]

          at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261) [:1.1.0.Final]

          at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88) [:6.0.0.Final]

          at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100) [:6.0.0.Final]

          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) [:6.0.0.Final]

          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [:6.0.0.Final]

          at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) [:6.0.0.Final]

          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [:6.0.0.Final]

          at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) [:6.0.0.Final]

          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [:6.0.0.Final]

          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [:6.0.0.Final]

          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654) [:6.0.0.Final]

          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [:6.0.0.Final]

          at java.lang.Thread.run(Thread.java:662) [:1.6.0_24]

      Caused by: javax.naming.NameNotFoundException: local not bound

          at org.jnp.server.NamingServer.getBinding(NamingServer.java:771) [:5.0.5.Final]

          at org.jnp.server.NamingServer.getBinding(NamingServer.java:779) [:5.0.5.Final]

          at org.jnp.server.NamingServer.getObject(NamingServer.java:785) [:5.0.5.Final]

          at org.jnp.server.NamingServer.lookup(NamingServer.java:443) [:5.0.5.Final]

          at org.jnp.server.NamingServer.lookup(NamingServer.java:399) [:5.0.5.Final]

          at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:728) [:5.0.5.Final]

          at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:688) [:5.0.5.Final]

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

          at org.jboss.resteasy.plugins.server.resourcefactory.JndiComponentResourceFactory.createResource(JndiComponentResourceFactory.java:53) [:6.0.0.Final]

          ... 25 more

       

      17:30:13,765 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/restapi].[default]] Servlet.service() for servlet default threw exception: org.jboss.resteasy.spi.UnhandledException: java.lang.RuntimeException: javax.naming.NameNotFoundException: local not bound

          at org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:225) [:6.0.0.Final]

          at org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:174) [:6.0.0.Final]

          at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:518) [:6.0.0.Final]

          at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:480) [:6.0.0.Final]

          at org.jboss.resteasy.core.SynchronousDispatcher.invokePropagateNotFound(SynchronousDispatcher.java:139) [:6.0.0.Final]

          at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:211) [:6.0.0.Final]

          at org.jboss.resteasy.plugins.server.servlet.FilterDispatcher.doFilter(FilterDispatcher.java:59) [:6.0.0.Final]

          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:6.0.0.Final]

          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]

          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [:6.0.0.Final]

          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) [:6.0.0.Final]

          at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181) [:6.0.0.Final]

          at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285) [:1.1.0.Final]

          at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261) [:1.1.0.Final]

          at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88) [:6.0.0.Final]

          at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100) [:6.0.0.Final]

          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) [:6.0.0.Final]

          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [:6.0.0.Final]

          at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) [:6.0.0.Final]

          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [:6.0.0.Final]

          at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) [:6.0.0.Final]

          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [:6.0.0.Final]

          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [:6.0.0.Final]

          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654) [:6.0.0.Final]

          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [:6.0.0.Final]

          at java.lang.Thread.run(Thread.java:662) [:1.6.0_24]

      Caused by: java.lang.RuntimeException: javax.naming.NameNotFoundException: local not bound

          at org.jboss.resteasy.plugins.server.resourcefactory.JndiComponentResourceFactory.createResource(JndiComponentResourceFactory.java:57) [:6.0.0.Final]

          at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:205) [:6.0.0.Final]

          at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:503) [:6.0.0.Final]

          ... 23 more

      Caused by: javax.naming.NameNotFoundException: local not bound

          at org.jnp.server.NamingServer.getBinding(NamingServer.java:771) [:5.0.5.Final]

          at org.jnp.server.NamingServer.getBinding(NamingServer.java:779) [:5.0.5.Final]

          at org.jnp.server.NamingServer.getObject(NamingServer.java:785) [:5.0.5.Final]

          at org.jnp.server.NamingServer.lookup(NamingServer.java:443) [:5.0.5.Final]

          at org.jnp.server.NamingServer.lookup(NamingServer.java:399) [:5.0.5.Final]

          at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:728) [:5.0.5.Final]

          at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:688) [:5.0.5.Final]

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

          at org.jboss.resteasy.plugins.server.resourcefactory.JndiComponentResourceFactory.createResource(JndiComponentResourceFactory.java:53) [:6.0.0.Final]

          ... 25 more