0 Replies Latest reply on Sep 26, 2014 6:29 AM by manujayakarunarathna

    javax.naming.NameNotFoundException for lookup to a session bean

    manujayakarunarathna

      First of all I am very new to EJB and JBoss hence all the answers and advices are welcome thankfully !

      I have used NetBeans 8.0.1 and develop an Enterprise application on JBoss 5.1.0  GA.

       

      The stateless session bean is as follow:

       

      Interface:

      @Local

      public interface mySBLocal {

          String say();

      }

       

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

      implementation:

       

      @Stateless

      public class mySB implements mySBLocal {

       

       

          public String say() {

              return "Hello";

          }

      }

       

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

      And how I access the session bean in servlet is below:

      InitialContext ctx;

                  try {

                      ctx = new InitialContext();

                 

         ejb = (mySBLocal) ctx.lookup("NewEE/mySBLocal/local");

         } catch (NamingException ex) {

                      Logger.getLogger(myServ.class.getName()).log(Level.SEVERE, null, ex);

                      out.println(ex.getMessage());

                  }

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

      For this I am getting an NameNotFoundException exception as below:

       

      javax.naming.NameNotFoundException: NewEE not bound

        at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)

        at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)

        at org.jnp.server.NamingServer.getObject(NamingServer.java:785)

        at org.jnp.server.NamingServer.lookup(NamingServer.java:396)

        at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:726)

        at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)

        at javax.naming.InitialContext.lookup(InitialContext.java:409)

        at myServ.processRequest(myServ.java:53)

        at myServ.doGet(myServ.java:77)

        at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)

        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)

        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)

        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)

        at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)

        at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)

        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

        at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)

        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)

        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)

        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)

        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)

        at java.lang.Thread.run(Thread.java:717)

       

       

      Could you please provide me a solution for this. I think problem is with lookup calling but I have no idea to resolve it yet. Thanks a lot !!!