3 Replies Latest reply on Mar 14, 2007 2:58 PM by Andrew Rubinger

    JNDI and Client Application

    Sean Alphonse Newbie


      ( I can't seem to find an answer to following question. Please bare with me. )

      I am trying to run a client application at the command line to connect to a deployed stateless bean.

      I have complied a SimpleSession ( a remote interface ) and SimpleSessionBean ( a stateless bean that implements SimpleSession ).
      I have complied both the interface and the bean and created a jar file with the following command:

      "jar cf SimpleSessionApp.ejb3 beans\*.java"

      I then placed the jar file in the deploy directory.

      I have created a client application with the following code:

      package client;

      import beans.SimpleSession;
      import javax.naming.InitialContext;

      public class SimpleSessionClient {
      public static void main( String args[] ) throws Exception {
      InitialContext ctx = new InitialContext();
      SimpleSession simpleSession = ( SimpleSession )ctx.lookup( "beans/SimpleSession/remote" );
      for( int i = 0; i < args.length; i++ ) {
      String returnedString = simpleSession.sendMessage( args[ i ] );
      System.out.println( "sent string: " + args[ i ] + ", received string: " + returnedString );
      I then compiled the code and tried running it at the command line with the following command:

      "java -Djava.naming.factory.initial=org.jnp.interfaces.
      NamingContextFactory -Djava.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces -Djava.naming.provider.url
      =localhost client.SimpleSessionClient Now is the time for all good men"

      I get the following error:

      Exception in thread "main" javax.naming.NameNotFoundException: beans 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:267)
      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:585)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
      at sun.rmi.transport.Transport$1.run(Transport.java:153)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
      at java.lang.Thread.run(Thread.java:595)
      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:625)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
      at javax.naming.InitialContext.lookup(Unknown Source)
      at client.SimpleSessionClient.main(SimpleSessionClient.java:9)