9 Replies Latest reply on May 3, 2005 11:53 AM by adrian.bigland

    RMIConnectorImpl: gone from 4?

      I used to use code like this in 3.2.3:

      RMIAdaptor adaptor = ic.lookup("jmx/rmi/RMIAdaptor");
      MBeanServer server = new RMIConnectorImpl(adaptor);

      I need to add a NotificationListener to an MBeanServer - if I use the adaptor it requires a serializable listener - presumably I would have to create a remote stub to my listener and send the stub for this to work...

      JMX remoting looks useful, but seems to require the remote MBeans to provide locators via JNDI for this to be practical.

      Does anyone know the 'canonical' way to access the MBeanServer now that the RMIConnectorImpl has gone? (If there is one :)

        • 1. Re: RMIConnectorImpl: gone from 4?
          dimitris
          • 2. Re: RMIConnectorImpl: gone from 4?

            Thanks for the reply, Dimitris.

            I think that MBeanServerConnection is just another interface for the RMIAdaptor. My problem is that the RMIAdaptor needs a serializable NotificationListener when you call addNotificationListener - I think this will be the case whether you call this through a reference to RMIAdaptor or MBeanServerConnection.

            When I wrapped the RMIAdaptor in an instance of RMIConnectorImpl in the past I didn't need to use a serializable NotificationListener - I assume that the connector used a remote proxy for my listener.

            My question really is - RMIConnectorImpl was removed in JBoss 4 - why? And what classes/methods replace it?

            Any ideas? Thanks,

            Adrian.

            • 3. Re: RMIConnectorImpl: gone from 4?
              dimitris

              I don't remember if you can directly register for notifications to the MBeanServerConnection object. I would guess that implicitly a remote callback object would be created on the client side under the hood to shield the remoteness. Try that first (or look at the sources :)

              I believe the main reason for changing this was JMX1.2 compliance.

              • 4. Re: RMIConnectorImpl: gone from 4?

                Well, I tried adding a notification listener using the RMIAdaptor, and it definitely adds the listener to the local JBoss MBeanServer - I got printouts on the server console, not my local console, with a simple test listener.

                This is pretty much what I expected, given that it insisted that the listeners be serializable.

                I can't easily browse the source code in JBoss 4 because the RMIAdaptor is only an interface - and the implementations seem to be dynamic proxies. I did a scan of the source for implementations, and couldn't find anything. The only thing I can do now is to look at the source for RMIConnectorImpl in 3.2.3 and see what it was doing.

                Is there any way we can add this question to the FAQ:

                how do I add a notification listener to a remote MBeanServer - so that I receive notifications on my client?

                Thanks,

                Adrian.

                • 5. Re: RMIConnectorImpl: gone from 4?
                  dimitris

                  Yes we need this, I'll add it when I find some time. :)

                  • 6. Re: RMIConnectorImpl: gone from 4?
                    starksm64

                    The handler for the org.jboss.jmx.adaptor.rmi.RMIAdaptor and org.jboss.jmx.adaptor.rmi.RMIAdaptorExt interfaces is the org.jboss.jmx.connector.invoker.InvokerAdaptorService found in the server module of the source download. This mapping is setup by the jmx-invoker-service.xml found in the deploy directory.

                    • 7. Re: RMIConnectorImpl: gone from 4?

                      I have successfully added a remote notification listener using the RMIAdaptor, but I had to do a bit of work first - there must be a better way! But in case anyone wants to know how I did it:

                      you need a remote version of the non-remote NotificationListener interface - there is one in JBoss 4: org.jboss.jmx.adaptor.rmi.RMINotificationListener which I reused.

                      create a RMI to JMX bridge class that converts remote handleNotification calls to standard non-remote versions, calling the handleNotification on your remote listener.

                      get UnicastRemoteObject to export this bridge class - so you now have a remote proxy that implements the remote interface and will remotely call your local bridge.

                      wrap the proxy in a JMX to RMI bridge (that must be serializable) so that you can send something over the wire that implements the non-remote handleNotification method, since you can't add the remote interface implementation to an MBeanServer.

                      send this over the wire using the RMIAdaptor. Easy! Except:
                      - You have to provide the final bridge with a GUID so that you can remove the listener later (you can't do this directly since you don't have a reference to the listener that was created via deserialization and added to the remote MBeanServer) - and you must also implement equals and hashCode to use the GUID.
                      - You also need to put the final proxy class into JBoss' classpath (create a jar containing this and put it in your server's lib directory).
                      - If you use JDK1.5 to run JBoss, and make your RMI to JMX bridge extend UnicastRemoteObject you have nothing further to do - otherwise you need to use rmic to create a remote stub (the remote proxy) and also include this in the jar - it needs to be on JBoss' classpath too.

                      Please don't tell me I could have done this with a one line change to an XML file somewhere...

                      • 8. Re: RMIConnectorImpl: gone from 4?

                        adrian, is your code available anywhere in the net? I need exactly that behaviour.

                        My notifications are also handled on the server but they should be handled on the client side. Please make your code public. Or even better... post it in the JMX FAQ Wiki...

                        thx
                        Marcel

                        • 9. Re: RMIConnectorImpl: gone from 4?

                          Marcel,

                          I've added a note in the JMX FAQ on the wiki. I've included the code for the classes I had to create, and some explanation of why I needed them - in case anyone can come up with a better solution.

                          Let me know if the instructions etc. are OK or fall short in any way and I'll fix the wiki note - or do it yourself, of course :)

                          Adrian.