0 Replies Latest reply on Jun 9, 2004 3:27 AM by maroni

    Registering an MBean in JNDI

    maroni Newbie

      I want to register my mbean with JNDI so that a client can retrieve the JNDIName and use the mbean. It works when I use the RMIAdapter instead, but I wanted to try the JNDI way.

      I bound my mbean to JNDI as follows (jndiname is "inmemory/maps/MapTest2":

       InitialContext rootCtx = new InitialContext();
       Name fullName = rootCtx.getNameParser("").parse(jndiName);
       NonSerializableFactory.rebind(fullName, this, true);

      And obviously, it could be bound successfully because when I look at the JNDIView list of names, I can see the following:

      +- inmemory (class: org.jnp.interfaces.NamingContext)
      | +- maps (class: org.jnp.interfaces.NamingContext)
      | | +- MapTest2 (class: mytest.mbean.JNDIMap)

      My client application tries to access the service now as follows:

      Object obj = getContext().lookup ("inmemory/maps/MapTest2");
      mytest.mbean.JNDIMap map = (mytest.mbean.JNDIMap)PortableRemoteObject.narrow(obj, mytest.mbean.JNDIMap.class);

      But it does not work. map is null. What is wrong with that code? Can anybody help me?