6 Replies Latest reply on Jun 22, 2002 9:40 AM by David Jencks

    JNDI lookup string

    Amit Likhyani Newbie

      I created an MBean which appears to be deployed correctly
      in the management console. I can't figure out how to have
      a client look it up in JNDI. My user-services.xml entry

      My MBean implements the ServiceMBean interface.

      public interface AmitServiceMBean extends ServiceMBean
      public String foo();

      If I invoke foo from the console, it works correctly.
      I have tried to look up my MBean using:

      No luck. Please help.

        • 1. Re: JNDI lookup string
          Adrian Brock Master

          You need to use a connector.
          I think these docs are 2.4
          and there is a mistake which is corrected in these
          forums if you search.

          If you are using 3.0 there is also an ejb connector.

          The idea behind these are that you lookup a "remote
          MBeanServer" from jndi, then you can access the MBean
          using that object.


          • 2. Re: JNDI lookup string
            David Jencks Master

            The only connection between jndi and jmx is that jndi services in jboss are implemented as mbeans. If you want something related to your mbean to be bound in jndi you have to bind it yourself. Consider using the NonSerializableObjectFactory so you get your original mbean back, not a serialized/deserialized copy.

            • 3. Re: JNDI lookup string
              Amit Likhyani Newbie

              Well, what we are trying to do is implement a
              singleton by making it an MBean. Is there a pattern
              that most JBoss developers adhere to to do this?
              Is binding my mbean to JNDI myself a commonly
              used pattern or am I missing something?

              • 4. Re: JNDI lookup string
                Amit Likhyani Newbie

                Is there an example of the use of NonSerializedObjectFactory?

                • 5. Re: JNDI lookup string
                  vishal Newbie

                  i have a clutch of mbeans i have implemented as singetons.
                  i think that was feasible because the underlying archtecture of JMX seems to point to an object that
                  is retained till it is not deregistered .
                  Am i correct in this assumption??

                  • 6. Re: JNDI lookup string
                    David Jencks Master

                    MBeans are indeed singletons in the sense that the MBeanServer manages particular object instances. On the other hand there is nothing preventing you from instantiating many mbeans that are instances of the same class, as long as they are identified by different object names.

                    Personally I tend to prefer to access mbeans by calling them through the mbean server. If I have a particularly heavily used method I usually supply a read-only Instance attribute (in other words a getInstance method in the MBean interface) that returns the instance to get the actual object for use.

                    For use of JNDI, I should have written NonSerializableFactory. One example is in server/src/main/org/jboss/jms/asf/ServerSessionPoolLoader.java.