[jboss-user] [EJB3] - Rest and EJB

Guru Prashanth Thanakodi do-not-reply at jboss.com
Sat Jul 16 08:02:16 EDT 2011


Guru Prashanth Thanakodi [http://community.jboss.org/people/guru.1306] created the discussion

"Rest and EJB"

To view the discussion, visit: http://community.jboss.org/message/615616#615616

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

Reply to this message by going to Community
[http://community.jboss.org/message/615616#615616]

Start a new discussion in EJB3 at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110716/524ebad3/attachment-0001.html 


More information about the jboss-user mailing list