2 Replies Latest reply on Feb 4, 2004 12:10 AM by zolmed75

    why servlet failed to use jndi, help

    dingmickey Newbie

      hi,
      i use jboss3.0.8 to deploy intrest(this example from jboss)
      I suffered a problem:
      when InterestServlet use jndi to lookup "java:comp/env/ejb/Interest"


      public void init() throws ServletException
      {
      try
      {
      // Get a naming context
      InitialContext jndiContext = new InitialContext();
      // Get a reference to the Interest Bean
      Object ref = jndiContext.lookup("java:comp/env/ejb/Interest");
      // Get a reference from this to the Bean's Home interface
      interestHome = (InterestHome) PortableRemoteObject.narrow(ref, InterestHome.class);
      }
      catch(Exception e)
      {
      throw new ServletException("Failed to lookup java:comp/env/ejb/Interest", e);
      }
      }



      jboss error�F
      15:49:32,031 INFO [Server] JBoss (MX MicroKernel) [3.0.8 (CVSTag=JBoss_3_0_8 Da
      te=200306050849)] Started in 0m:23s:243ms
      15:50:44,475 WARN [jbossweb] WARNING:
      javax.servlet.ServletException: Failed to lookup java:comp/env/ejb/Interest
      at org.jboss.docs.interest.InterestServlet.init(InterestServlet.java:45)

      at javax.servlet.GenericServlet.init(GenericServlet.java:256)
      at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java
      :280)
      at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:333
      )
      at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicati
      onHandler.java:294)
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:5
      58)
      at org.mortbay.http.HttpContext.handle(HttpContext.java:1714)
      at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplication
      Context.java:505)
      at org.mortbay.http.HttpContext.handle(HttpContext.java:1664)
      at org.mortbay.http.HttpServer.service(HttpServer.java:879)
      at org.jboss.jetty.Jetty.service(Jetty.java:460)
      at org.mortbay.http.HttpConnection.service(HttpConnection.java:770)
      at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:932)
      at org.mortbay.http.HttpConnection.handle(HttpConnection.java:787)
      at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:
      201)
      at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:289)
      at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:454)
      getRootCause():
      javax.naming.NameNotFoundException: interest not bound
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:503)
      at org.jnp.server.NamingServer.getObject(NamingServer.java:509)
      at org.jnp.server.NamingServer.lookup(NamingServer.java:253)
      at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
      at sun.rmi.transport.Transport$1.run(Transport.java:148)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
      60)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
      .java:701)
      at java.lang.Thread.run(Thread.java:536)
      at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Stream
      RemoteCall.java:247)
      at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:
      223)
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
      at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:493)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:472)
      at javax.naming.InitialContext.lookup(InitialContext.java:347)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:588)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:624)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:472)
      at javax.naming.InitialContext.lookup(InitialContext.java:347)
      at org.jboss.docs.interest.InterestServlet.init(InterestServlet.java:39)

      at javax.servlet.GenericServlet.init(GenericServlet.java:256)
      at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java
      :280)
      at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:333
      )
      at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicati
      onHandler.java:294)
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:5
      58)
      at org.mortbay.http.HttpContext.handle(HttpContext.java:1714)
      at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplication
      Context.java:505)
      at org.mortbay.http.HttpContext.handle(HttpContext.java:1664)
      at org.mortbay.http.HttpServer.service(HttpServer.java:879)
      at org.jboss.jetty.Jetty.service(Jetty.java:460)
      at org.mortbay.http.HttpConnection.service(HttpConnection.java:770)
      at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:932)
      at org.mortbay.http.HttpConnection.handle(HttpConnection.java:787)
      at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:
      201)
      at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:289)
      at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:454)

      help me!