0 Replies Latest reply on Sep 7, 2005 12:41 PM by Tom Coupland

    StringThresholdMonitoring Beans won't work

    Tom Coupland Newbie

      Hey everybody,

      Trying to implement a StringThresholdMoniter to monitor a small MBean i've made that trys to connect to a servlet (that i've also made) and if successful sets a String to 'availible', but the monitor keeps throwing this rather annoying error

      java.lang.RuntimeException: Failed to compare threshold, mbean failure
       at org.jboss.monitor.StringThresholdMonitor.testThreshold(StringThresholdMonitor.java:54)
       at org.jboss.monitor.JBossMonitor.run(JBossMonitor.java:204)
       at java.lang.Thread.run(Thread.java:595)

      Now i've gone through the JBoss code to try and find out where this comes from and have found a rather poorly coded bit of exception handling in the StringThresholdMonitor, namely

      public class StringThresholdMonitor extends JBossMonitor implements StringThresholdMonitorMBean
       protected String thresholdString;
       protected boolean equalityTriggersAlert;
       protected void testThreshold()
       if (alertSent) return;
       String value = null;
       value = (String)getServer().getAttribute(observedObject, attribute);
       if (equalityTriggersAlert) // alert trigger when value == threshold
       if (!thresholdString.equals(value))
       else // alert triggered when value != threshold
       if (thresholdString.equals(value))
       catch (Exception e)
       throw new RuntimeException("Failed to compare threshold, mbean failure");

      To my mind this is very slack, fancy not even passing on the type of the initial exception!

      Anyway heres my XML moniter as it appears in my moniters.xml file

      <mbean code="org.jboss.monitor.StringThresholdMonitor"
       <attribute name="MonitorName">PostBox Monitor Alerter</attribute>
       <attribute name="ObservedObject">Meta:monitor=PostBoxMonitor</attribute>
       <attribute name="ObservedAttribute">servletAvailible</attribute>
       <attribute name="Threshold">availible</attribute>
       <attribute name="Period">1000</attribute>
       <attribute name="EqualityTriggersAlert">false</attribute>
       <attribute name="Enabled">true</attribute>
       <depends-list optional-attribute-name="AlertListeners"> <depends-list-element>jboss.alerts:service=ConsoleAlertListener</depends-list-element> <!--<depends-list-element>jboss.alerts:service=EmailAlertListener</depends-list-element> not avalible yet-->

      I've run checks and the String servletAvailible is being set correctly in both cases, ie when its up and when its down.

      I hope someone can help me with this as otherwise i'm gonna have to make some changes to that class and rebuild me JBoss just to get a proper error out of it.

      As always critque/comments/ideas/surgestions welcome