5 Replies Latest reply on Sep 2, 2004 5:51 AM by Peter Backx

    How to listen for remote notifications?

    Carsten Diekmann Newbie

      Can anybody tell me how to use the org.jboss.jmx.connector.notification package? I want to a register a listener that gets notified about events on a remote mbean server. I already noticed the existence of RMINotificationListener and RMIClientNotificationListener, but I'm not sure if they solve my problem, respectively how to use them.

      Perhaps someone can give me some hints...

        • 1. Re: How to listen for remote notifications?
          Adrian Brock Master

          http://main.jboss.org/thread.jsp?forum=63&thread=11734

          This thread discusses the 2.4.4 example code
          available at
          http://www.jboss.org/online-manual/HTML/ch13s39.html

          It sets up a remote notification listener on all
          MBeans within JBoss.

          Some of the package and class names have changed
          in 3.0

          Regards,
          Adrian

          • 2. Re: How to listen for remote notifications?
            Carsten Diekmann Newbie

            Hi Adrian,

            thanks for your help. If things haven't changed too much in JBoss 3 the docs you mentioned should give me sufficient support...

            Best regards

            Carsten

            • 3. Re: How to listen for remote notifications?
              Peter Backx Newbie

              Sorry to bring up this old thread, but I have the same questions and the links don't work anymore. How does one setup a remote notification listener? I can't seem to find any help in the JBoss docs and the information on the wiki is for listener MBeans deployed on the server.

              What I tried already (on the client) is to invoke the addNotificationListener method on the RMIAdaptor with a implementation of an RMINotificationtListener, however I keep getting a java.io.NotSerializableException on this:

               public class MyRMIListener implements RMINotificationListener {
               public void handleNotification(javax.management.Notification notification, Object obj)
               throws java.rmi.RemoteException {
               System.out.println("\nReceived notification: " + notification);
               }
               }
              

              So I guess it's a little more complicated than that ...

              regards and thanks in advance,
              Peter

              • 4. Re: How to listen for remote notifications?
                Elias Ross Master


                Likely the notification object you are passing isn't serializable. What is the stack trace?

                • 5. Re: How to listen for remote notifications?
                  Peter Backx Newbie

                  addNotificationListener on an RMIAdaptor throws the following exception when adding the notification listener I put in my previous message:

                  java.rmi.MarshalException: error marshalling arguments; nested exception is:
                   java.io.NotSerializableException: be.ugent.pbackx.client.MyRMIListener
                   at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:129)
                   at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
                   at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:135)
                   at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:96)
                   at org.jboss.jmx.connector.invoker.client.InvokerAdaptorClientInterceptor.invoke(InvokerAdaptorClientInterceptor.java:58)
                   at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:53)
                   at org.jboss.proxy.ClientMethodInterceptor.invoke(ClientMethodInterceptor.java:55)
                   at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
                   at $Proxy1.addNotificationListener(Unknown Source)
                   at be.ugent.pbackx.util.EJBUtil.addNotificationListener_aroundBody82(EJBUtil.java:143)
                   at be.ugent.pbackx.util.EJBUtil.addNotificationListener_aroundBody84(EJBUtil.java:143)
                   at be.ugent.pbackx.util.EJBUtil.addNotificationListener(EJBUtil.java)
                   at be.ugent.pbackx.client.SimpleMonitorPanel.<init>(SimpleMonitorPanel.java:36)
                   at be.ugent.pbackx.client.GUIManager.initComponents_aroundBody122(GUIManager.java:83)
                   at be.ugent.pbackx.client.GUIManager.initComponents(GUIManager.java)
                   at be.ugent.pbackx.client.GUIManager.initComponents_aroundBody0(GUIManager.java:26)
                   at be.ugent.pbackx.client.GUIManager.<init>(GUIManager.java:26)
                   at be.ugent.pbackx.client.GUIManager.main(GUIManager.java:171)
                  Caused by: java.io.NotSerializableException: be.ugent.pbackx.client.MyRMIListener
                   at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
                   at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1224)
                   at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1050)
                   at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
                   at org.jboss.invocation.MarshalledValue.<init>(MarshalledValue.java:57)
                   at org.jboss.invocation.MarshalledInvocation.writeExternal(MarshalledInvocation.java:477)
                   at java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1264)
                   at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1245)
                   at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
                   at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
                   at sun.rmi.server.UnicastRef.marshalValue(UnicastRef.java:265)
                   at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:124)
                   ... 17 more
                  


                  Just for the record the complete MyRMIListener code:
                  package be.ugent.pbackx.client;
                  
                  import org.jboss.jmx.adaptor.rmi.RMINotificationListener;
                  
                  public class MyRMIListener implements RMINotificationListener {
                   public void handleNotification(javax.management.Notification notification, Object obj) {
                   System.out.println("\nReceived notification: " + notification);
                   }
                  }