2 Replies Latest reply on Jul 6, 2006 5:22 AM by mp mp

    JNDI bind problem

    Javier Leyba Newbie


      Hi

      I want to get my application to bind objects to jboss JNDI the I did a simple client to try to make a bind like this:


      
      
      public static void main(String[] args) {
       try {
       Hashtable p = new Hashtable();
       p.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
       p.put("java.naming.provider.url", "jnp://172.31.112.9:2199");
       p.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
      
      
       Context c = new InitialContext(p);
       System.out.println("trying to bind");
       c.bind("cf", "sdvsdv");
       System.out.println("bind done");
      
       } catch (Exception e) {
       e.printStackTrace();
       }
      



      But I´m receiving the following exception:

      Intento hacer bind
      javax.naming.NameAlreadyBoundException
       at org.jnp.server.NamingServer.bind(NamingServer.java:129)
       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:460)
       at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
       at java.lang.Thread.run(Thread.java:595)
       at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.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.bind(Unknown Source)
       at org.jnp.interfaces.NamingContext.bind(NamingContext.java:551)
       at org.jnp.interfaces.NamingContext.bind(NamingContext.java:516)
       at javax.naming.InitialContext.bind(InitialContext.java:355)
       at Test.main(Test.java:27)
      



      Where line 27 is
      c.bind("cf", "sdvsdv");


      Could somebody tell me how could I bind objects in JBoss JNDI ?

      Thanks in advance

      J