3 Replies Latest reply on Jun 7, 2004 10:19 PM by gorano

    Questions about standard MBean Example

    maroni Newbie

      I have deployed the very simple standard MBean example of the JBoss Administration and Development Book (3.2.3) which binds a HashMap into JNDI, and then I played with it around, but I got some problems. So here are my questions:

      1. The HashMap was successfully bound into JNDI, and I can see my service on the JMX console. Then I wrote a client which does a lookup on the HashMap, as follows:
      map = (HashMap) getContext().lookup("inmemory/maps/MapTest2");

      Seems to be okay, because I don´t get any NamingException. But how can I use the HashMap then? How can I access the content now? When I want to use the map, I get a NullPointerException. Why is it null??

      2. I would like to call functions on my mbean, from a client or another mbean. Do I have to use an adapter for that, or can I access the mbean directly via JNDI?? How can I give my mbean a JNDI name?

      3. In the mbean´s start() method I tried to create a serial connection to a PLC. But when I deploy the SAR file, the usage of the classes for the serial communication causes a NoClassDefFoundError Exception. But I added the javax.comm package to my Eclipse project, and when I put the same serial port access code into my client application (within the same project), it works and I don´t get any exception. So why can´t my mbean find these classes? Do I have to add something to the descriptor file??

      I would really like to use my mbean...


        • 1. Re: Questions about standard MBean Example
          gorano Newbie

          Put the comm-files in the following JDK directories:

          j2sdk/jre/lib/javax.comm.properties
          j2sdk/jre/lib/ext/comm.jar
          j2sdk/jre/lib/i386/win32com.dll (or equivalent for linux)

          You can access an MBean remotely, but normal usage is to use the MBean as a framework for your application. Gives you a nice way
          of running applications that can be controlled and monitored via the
          JMX console. A bonus is also that you get persistence for your
          parameters.

          Create a thread in the start method and place your application
          specific code within this thread.

          /G

          /G

          • 2. Re: Questions about standard MBean Example
            maroni Newbie

            Thanks for the reply, but it still does not work. I had already put all these files into the correct directory, but I still get a NoClassDefFound exception when deploying my mbean. But the same code works in my standalone client appliciation.
            Seems as if JBoss needs a special hint to know where to look for the classes, I don´t know.
            When I add the comm.jar file to my mbean SAR, then it works, but sorry, this cannot be the right way to do so???

            What about the MBean access from a client? So you say that it´s possible to use the MBean directly, without using an adapter, but you don´t say how this can be done. Would be nice to know. Please tell me.

            And what about the HashMap access??

            • 3. Re: Questions about standard MBean Example
              gorano Newbie

              I am using the comm library for serial port communication from an MBean. My MBean code do not have any problems to find the classes.
              Play around with it a bit more!

              You can make the MBean an RMI object or use the RMIAdapter.
              I also saw something in the Admin documents about client access
              to MBeans using an invoker.

              /G