2 Replies Latest reply: Oct 27, 2010 10:35 AM by 808472 RSS

    Can't find my MBean in VisualVM or JConsole

    808472
      I have a MBean that I'm deploying as part of an ear onto Glassfish. Using JConsole or VisualVM I can't find the MBean. As far as I can tell it's deploying correctly. I've put the class below, in case the problem is in there. Any ideas?

      public class TestEmitter implements TestEmitterMBean, NotificationEmitter {
      private NotificationBroadcasterSupport broadcaster = new NotificationBroadcasterSupport();
      private long seqNumber;

      private static final String TYPE_REQUESTED = "requested";
      private static final String TYPE_SUCCESSFUL = "request successful";
      private static final String TYPE_FAILED = "request failed";

      public TestEmitter(){
      }

      @Override
      public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws IllegalArgumentException {
      broadcaster.addNotificationListener(listener, filter, handback);
      }

      @Override
      public MBeanNotificationInfo[] getNotificationInfo() {
      return new MBeanNotificationInfo[]{
      new MBeanNotificationInfo(new String[]{TYPE_REQUESTED, TYPE_SUCCESSFUL, TYPE_FAILED},
      javax.management.Notification.class.getName(), "Notifications")};
      }

      @Override
      public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException {
      broadcaster.removeNotificationListener(listener);
      }

      @Override
      public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException {
      broadcaster.removeNotificationListener(listener, filter, handback);
      }

      public synchronized long getNextSeqNumber() {
      return seqNumber++;
      }

      @Override
      public void sendRequestNotification() {
      Notification notification = new Notification(TYPE_REQUESTED,this,getNextSeqNumber());
      broadcaster.sendNotification(notification);
      }

      @Override
      public void sendSuccessfulNotification() {
      Notification notification = new Notification(TYPE_SUCCESSFUL,this,getNextSeqNumber());
      broadcaster.sendNotification(notification);
      }

      @Override
      public void sendFailedNotification() {
      Notification notification = new Notification(TYPE_FAILED,this,getNextSeqNumber());
      broadcaster.sendNotification(notification);
      }


      }