0 Replies Latest reply on May 15, 2006 2:48 AM by nancy.aggarwal

    When Binding exception-already Bind,but lookup is null

    nancy.aggarwal

      Hi,

      I want to bind my class object to jndi.I have created MBEAN taking help from following link :
      http://www.huihoo.com/jboss/online_manual/3.0/ch13s26.html

      just changed

      private HashMap contextMap = new HashMap();


      to

      private MyClass classContext=new MyClass();


      in JNDIMap MBean That Implements Service Methods example.


      When i am trying to lookup from outside applciation,it is giving null but when i tries to bind give:

      javax.naming.NameAlreadyBoundException
       at org.jnp.server.NamingServer.bind(NamingServer.java:144)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)


      Mycode to lookup is:

      InitialContext initialContext = null;
       Hashtable environment = new Hashtable();
       environment.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
       environment.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
       environment.put(Context.PROVIDER_URL, "jnp://localhost:1099");
       try {
       initialContext = new InitialContext(environment);
       initialContext.bind("WebServiceInvoker",new WebServiceInvoker());
       Object webserviceURL=initialContext.lookup("WebServiceInvoker");
       System.out.println(webserviceURL);
       } catch (NamingException e) {
       e.printStackTrace();
       }