1 Reply Latest reply on Mar 16, 2003 8:25 PM by Adrian Brock

    problem with addNotification

    sujit Newbie

      Hi
      When adding the notifications, sometimes the timer mbean is throwing the folowing exception.
      java.lang.IllegalArgumentException: Timer notification date before the current
      ate
      at javax.management.timer.Timer.addNotification(Timer.java:434)
      at javax.management.timer.Timer.addNotification(Timer.java:548)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1
      30)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1
      25)

      We are passing the following arguments to the addNotification method of the timer mbean.
      Object[] objectArray = {"testa", "TEST", data, new Date(System.currentTimeMillis())};
      String[] stringArray = { "java.lang.String", "java.lang.String", "java.lang.Object", "java.util.Date"};
      server.invoke(objectName,"addNotification",objectArray,stringArray);

      Could you please tell me the solution to get rid of this exception. One solution is to add some time( 500 milliseconds) so that the current time always exceeds that system current time in the addNotification method which is as follows.

      Object[] objectArray = {"testa", "TEST", data, new Date(System.currentTimeMillis()+500)};
      String[] stringArray = { "java.lang.String", "java.lang.String", "java.lang.Object", "java.util.Date"};
      server.invoke(objectName,"addNotification",objectArray,stringArray);

      But, we don't want to use it. Could you please tell me some other solution to solve this issue!!

        • 1. Re: problem with addNotification
          Adrian Brock Master

          Before JMX 1.2 the time MUST be in the future.
          With JMX 1.2 (not yet implemented in JBossMX)
          a date in the past should be interpreted as "now".

          One solution is the one you found, simply add
          a few milli-seconds to "now" to make sure when the
          test is performed it is not in the past.

          Regards,
          Adrian