<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
Rest and EJB
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/guru.1306">Guru Prashanth Thanakodi</a> in <i>EJB3</i> - <a href="http://community.jboss.org/message/615616#615616">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>I am trying to integrate EJB3.1 and rest.</p><p>The @EJB injection is not working.</p><p>Here is my program,</p><p>------------------------------------------------------------------</p><p>Rest Layer</p><p>------------------------------------------------------------</p><p>package com.emc.testrest;</p><p>import javax.ejb.*;</p><p>import javax.ws.rs.*;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>@Path("restlayer")</p><p>@Stateless</p><p>public class restlayer {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>@EJB</p><p>private testlocal testObject;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>@Path("/enter")</p><p>@GET</p><p>public int enter()</p><p>{</p><p>    int x =4;</p><p>    x = x+5;</p><p>    x = testObject.runtest();</p><p>    return x;</p><p>}</p><p>    </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>--------------------------------</p><p>EJB</p><p>------------------------------</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>package com.emc.testrest;</p><p>import javax.ejb.*;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>@Stateless</p><p>public class testlocalbean implements testlocal</p><p>{</p><p>    private int inittest; </p><p>    public testlocalbean()</p><p>    {</p><p>        inittest =4;        </p><p>    }</p><p>    </p><p>    @Override</p><p>    public int runtest()</p><p>    {</p><p>        int x=1;</p><p>        x= x+ 8;</p><p>        return x;</p><p>    }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>package com.emc.testrest;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>import javax.ejb.*;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>@Local</p><p>public interface testlocal </p><p>{</p><p>    public int runtest();    </p><p>    </p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>When I deploy Jboss displays these messages</p><p>17:17:17,375 INFO  [org.jboss.ejb3.session.SessionSpecContainer] Starting jboss.j2ee:jar=restapi.war,name=restlayer,service=EJB3</p><p>17:17:17,375 INFO  [org.jboss.ejb3.EJBContainer] STARTED EJB: com.emc.testrest.restlayer ejbName: restlayer</p><p>17:17:17,375 INFO  [org.jboss.ejb3.proxy.impl.jndiregistrar.JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>17:17:17,375 WARN  [org.jboss.ejb3.TimerServiceContainer] EJBTHREE-2193: using deprecated TimerServiceFactory for restoring timers</p><p>17:17:17,375 INFO  [org.jboss.web.tomcat.service.deployers.TomcatDeployment] deploy, ctxPath=/restapi</p><p>17:17:17,437 INFO  [org.jboss.ejb3.nointerface.impl.jndi.AbstractNoInterfaceViewBinder] Binding the following entry in Global JNDI for bean:restlayer</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    restlayer/no-interface -> EJB3.1 no-interface view</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>But when I call rest client to call this interface I get the following Exception</p><p><span>Restcall:</span><a class="jive-link-external-small" href="http://localhost:8080/restapi/restlayer/enter" target="_blank">http://localhost:8080/restapi/restlayer/enter</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>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</p><p>    at org.jboss.resteasy.plugins.server.resourcefactory.JndiComponentResourceFactory.createResource(JndiComponentResourceFactory.java:57) [:6.0.0.Final]</p><p>    at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:205) [:6.0.0.Final]</p><p>    at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:503) [:6.0.0.Final]</p><p>    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:480) [:6.0.0.Final]</p><p>    at org.jboss.resteasy.core.SynchronousDispatcher.invokePropagateNotFound(SynchronousDispatcher.java:139) [:6.0.0.Final]</p><p>    at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:211) [:6.0.0.Final]</p><p>    at org.jboss.resteasy.plugins.server.servlet.FilterDispatcher.doFilter(FilterDispatcher.java:59) [:6.0.0.Final]</p><p>    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:6.0.0.Final]</p><p>    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]</p><p>    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [:6.0.0.Final]</p><p>    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) [:6.0.0.Final]</p><p>    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181) [:6.0.0.Final]</p><p>    at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285) [:1.1.0.Final]</p><p>    at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261) [:1.1.0.Final]</p><p>    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88) [:6.0.0.Final]</p><p>    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100) [:6.0.0.Final]</p><p>    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) [:6.0.0.Final]</p><p>    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [:6.0.0.Final]</p><p>    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) [:6.0.0.Final]</p><p>    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [:6.0.0.Final]</p><p>    at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) [:6.0.0.Final]</p><p>    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [:6.0.0.Final]</p><p>    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [:6.0.0.Final]</p><p>    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654) [:6.0.0.Final]</p><p>    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [:6.0.0.Final]</p><p>    at java.lang.Thread.run(Thread.java:662) [:1.6.0_24]</p><p>Caused by: javax.naming.NameNotFoundException: local not bound</p><p>    at org.jnp.server.NamingServer.getBinding(NamingServer.java:771) [:5.0.5.Final]</p><p>    at org.jnp.server.NamingServer.getBinding(NamingServer.java:779) [:5.0.5.Final]</p><p>    at org.jnp.server.NamingServer.getObject(NamingServer.java:785) [:5.0.5.Final]</p><p>    at org.jnp.server.NamingServer.lookup(NamingServer.java:443) [:5.0.5.Final]</p><p>    at org.jnp.server.NamingServer.lookup(NamingServer.java:399) [:5.0.5.Final]</p><p>    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:728) [:5.0.5.Final]</p><p>    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:688) [:5.0.5.Final]</p><p>    at javax.naming.InitialContext.lookup(InitialContext.java:392) [:1.6.0_24]</p><p>    at org.jboss.resteasy.plugins.server.resourcefactory.JndiComponentResourceFactory.createResource(JndiComponentResourceFactory.java:53) [:6.0.0.Final]</p><p>    ... 25 more</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>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</p><p>    at org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:225) [:6.0.0.Final]</p><p>    at org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:174) [:6.0.0.Final]</p><p>    at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:518) [:6.0.0.Final]</p><p>    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:480) [:6.0.0.Final]</p><p>    at org.jboss.resteasy.core.SynchronousDispatcher.invokePropagateNotFound(SynchronousDispatcher.java:139) [:6.0.0.Final]</p><p>    at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:211) [:6.0.0.Final]</p><p>    at org.jboss.resteasy.plugins.server.servlet.FilterDispatcher.doFilter(FilterDispatcher.java:59) [:6.0.0.Final]</p><p>    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:6.0.0.Final]</p><p>    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]</p><p>    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [:6.0.0.Final]</p><p>    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) [:6.0.0.Final]</p><p>    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181) [:6.0.0.Final]</p><p>    at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285) [:1.1.0.Final]</p><p>    at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261) [:1.1.0.Final]</p><p>    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88) [:6.0.0.Final]</p><p>    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100) [:6.0.0.Final]</p><p>    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) [:6.0.0.Final]</p><p>    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [:6.0.0.Final]</p><p>    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) [:6.0.0.Final]</p><p>    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [:6.0.0.Final]</p><p>    at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) [:6.0.0.Final]</p><p>    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [:6.0.0.Final]</p><p>    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [:6.0.0.Final]</p><p>    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654) [:6.0.0.Final]</p><p>    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [:6.0.0.Final]</p><p>    at java.lang.Thread.run(Thread.java:662) [:1.6.0_24]</p><p>Caused by: java.lang.RuntimeException: javax.naming.NameNotFoundException: local not bound</p><p>    at org.jboss.resteasy.plugins.server.resourcefactory.JndiComponentResourceFactory.createResource(JndiComponentResourceFactory.java:57) [:6.0.0.Final]</p><p>    at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:205) [:6.0.0.Final]</p><p>    at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:503) [:6.0.0.Final]</p><p>    ... 23 more</p><p>Caused by: javax.naming.NameNotFoundException: local not bound</p><p>    at org.jnp.server.NamingServer.getBinding(NamingServer.java:771) [:5.0.5.Final]</p><p>    at org.jnp.server.NamingServer.getBinding(NamingServer.java:779) [:5.0.5.Final]</p><p>    at org.jnp.server.NamingServer.getObject(NamingServer.java:785) [:5.0.5.Final]</p><p>    at org.jnp.server.NamingServer.lookup(NamingServer.java:443) [:5.0.5.Final]</p><p>    at org.jnp.server.NamingServer.lookup(NamingServer.java:399) [:5.0.5.Final]</p><p>    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:728) [:5.0.5.Final]</p><p>    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:688) [:5.0.5.Final]</p><p>    at javax.naming.InitialContext.lookup(InitialContext.java:392) [:1.6.0_24]</p><p>    at org.jboss.resteasy.plugins.server.resourcefactory.JndiComponentResourceFactory.createResource(JndiComponentResourceFactory.java:53) [:6.0.0.Final]</p><p>    ... 25 more</p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/615616#615616">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in EJB3 at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>