2 Replies Latest reply on Dec 7, 2008 8:49 PM by Rama Krishna

    Exception in thread "main" javax.naming.NameNotFoundExceptio

    Rama Krishna Newbie

      BankRemote.java
      import javax.ejb.Remote;

      @Remote
      public interface BankRemote {
      public String getName();

      }

      BankImpl.java
      import javax.ejb.Remote;
      import javax.ejb.Stateless;

      @Stateless
      public class BankImpl implements BankRemote{
      public String getName() {
      // TODO Auto-generated method stub
      return "Hello Bank";

      }

      }

      Client.java
      import java.util.Hashtable;

      import javax.naming.Context;
      import javax.naming.InitialContext;
      import javax.naming.NamingException;


      public class Client {

      /**
      * @param args
      */
      public static void main(String[] args) throws NamingException{
      // TODO Auto-generated method stub
      Hashtable ht=new Hashtable();
      ht.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
      ht.put(Context.PROVIDER_URL,"jnp://localhost:1099");
      ht.put(Context.URL_PKG_PREFIXES,"org.jboss.naming.jnp.interfaces");
      Context ic=new InitialContext(ht);
      BankRemote br=(BankRemote)ic.lookup("BankRemote");
      System.out.println(br.getName());

      }

      }

      i have copied jbossall-client.jar file in the classpath and run the client prg it throws exception i.e.

      Exception in thread "main" javax.naming.NameNotFoundException: BankRemote not bound
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
      at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
      at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305)
      at sun.rmi.transport.Transport$1.run(Transport.java:159)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
      at java.lang.Thread.run(Thread.java:619)
      at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
      at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
      at sun.rmi.server.UnicastRef.invoke(Unknown Source)
      at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
      at javax.naming.InitialContext.lookup(Unknown Source)
      at Client.main(Client.java:20)