6 Replies Latest reply on Feb 18, 2009 10:05 AM by brian.stansberry

    Problem singleton scheduling in a clustered JBoss 4.02 (java

      Hi,

      I'm trying to schedule a singleton in an HA env. My application server is JBoss 4.0.2 in a cluster environment with 2 nodes. But I must say it is a much hard work to do! The documentation is not enough and I'm not so expert in JBoss and MBean realm.

      I followed the examples in the JBoss develop guide but something doesn't work yet. And now I'm in trouble!

      This is the code excerpt:

      public class SchedulableService extends ServiceMBeanSupport implements SchedulableServiceMBean
      {
      
       public SchedulableService() { }
      
       public void run(String amb, int num, boolean gen) {
       Jobber.Run(amb, num, gen);
       }
      
      }
      
      public interface SchedulableServiceMBean extends ServiceMBean
      {
       public abstract void run(String amb, int num, boolean gen);
      }
      
      


      Here is the jboss-service.xml file for the configuration of the SAR file:

      
      <server>
      
      <mbean code="it.se.bt.comm.em.SchedulableService"
       name="jboss.schedule:service=HASchedulable">
      </mbean>
      
      <mbean code="org.jboss.varia.scheduler.ScheduleManager"
       name="jboss:service=ScheduleManager">
       <attribute name="StartAtStartup">true</attribute>
      </mbean>
      
      <mbean code="org.jboss.varia.scheduler.SingleScheduleProvider"
       name="jboss:service=HASingleScheduleProvider">
       <depends>jboss:service=mypartition</depends>
       <depends>jboss:service=ScheduleManager</depends>
       <depends>jboss.schedule:service=HASchedulable</depends>
      
       <attribute name="PartitionName">mypartition</attribute>
       <attribute name="HASingleton">true</attribute>
       <attribute name="ScheduleManagerName">jboss:service=ScheduleManager</attribute>
       <attribute name="TargetName">jboss.schedule:service=HASchedulable</attribute>
       <attribute name="TargetMethod">run( TPD , 16 , true)</attribute>
       <attribute name="StartDate">NOW</attribute>
       <attribute name="Period">60000</attribute>
       <attribute name="Repetitions">-1</attribute>
      
      </mbean>
      
      </server>
      
      


      When I deploy the SAR file I get this Exception:

      
      2009-02-04 13:36:59,039 ERROR [org.jboss.varia.scheduler.ScheduleManager$MBeanListener] Invoke of the Schedulable MBean failed
      javax.management.ReflectionException
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:216)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
       at org.jboss.varia.scheduler.ScheduleManager$MBeanListener.handleNotification(ScheduleManager.java:593)
       at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at org.jboss.mx.notification.NotificationListenerProxy.invoke(NotificationListenerProxy.java:138)
       at $Proxy9.handleNotification(Unknown Source)
       at javax.management.NotificationBroadcasterSupport.handleNotification(NotificationBroadcasterSupport.java:257)
       at javax.management.NotificationBroadcasterSupport$SendNotifJob.run(NotificationBroadcasterSupport.java:322)
       at javax.management.NotificationBroadcasterSupport$1.execute(NotificationBroadcasterSupport.java:307)
       at javax.management.NotificationBroadcasterSupport.sendNotification(NotificationBroadcasterSupport.java:229)
       at javax.management.timer.Timer.sendNotification(Timer.java:1237)
       at javax.management.timer.Timer.notifyAlarmClock(Timer.java:1206)
       at javax.management.timer.TimerAlarmClock.run(Timer.java:1289)
       at java.util.TimerThread.mainLoop(Timer.java:512)
       at java.util.TimerThread.run(Timer.java:462)
      Caused by: java.lang.IllegalArgumentException: Unable to find operation run(TPD,16,true)
       ... 17 more
      
      


      I think the problem is related to the "TargetMethod" invokatio but I cannot understand what is wrong.

      Does anyone have any idea about it?

      thanks


        • 1. Re: Problem singleton scheduling in a clustered JBoss 4.02 (
          ryandavid

          It seems as "run(TPD,16,true)" that you wrote in XML file doesn't reference to Java syntax or something like that. Maybe the logic is different.

          It would be helpful to get some documentation about the standard way to call a method of MBean object.

          Do you know more docs ?

          • 2. Re: Problem singleton scheduling in a clustered JBoss 4.02 (

            You are righe. I think the same thing: the problem could be related to the RUN parameters. But I have another doubt: could it be related to some class reflection problem?

            It could seem it tries to find a RUN method that it doesn't find.

            I checked the documentation and the Internet google world but I always have the same example with HIT, NOTIFICATIONS and so on...

            It is a little bit frustrating...

            cheers

            ken

            • 3. Re: Problem singleton scheduling in a clustered JBoss 4.02 (
              ryandavid

              It's strange that this topic has been read over 60 times but nobody doesn't know some information

              • 4. Re: Problem singleton scheduling in a clustered JBoss 4.02 (

                mhhhh...do I have to use another application server? Please could anyone answer in this forum?

                • 5. Re: Problem singleton scheduling in a clustered JBoss 4.02 (

                  Probably there isn't a valid answer to you question, or probably nobody use JBoss in such a way... :-)

                  • 6. Re: Problem singleton scheduling in a clustered JBoss 4.02 (
                    brian.stansberry

                    Looking at the javadoc for the 4.0.2 version of SingleScheduleProvider I don't see a way to pass in the kind of arguments you want:

                     /**
                     * Sets the method name to be called on the Schedulable MBean. It can optionally be
                     * followed by an opening bracket, list of attributes (see below) and a closing bracket.
                     * The list of attributes can contain:
                     * <ul>
                     * <li>NOTIFICATION which will be replaced by the timers notification instance
                     * (javax.management.Notification)</li>
                     * <li>DATE which will be replaced by the date of the notification call
                     * (java.util.Date)</li>
                     * <li>REPETITIONS which will be replaced by the number of remaining repetitions
                     * (long)</li>
                     * <li>SCHEDULER_NAME which will be replaced by the Object Name of the Scheduler
                     * (javax.management.ObjectName)</li>
                     * <li>any full qualified Class name which the Scheduler will be set a "null" value
                     * for it</li>
                     * </ul>
                     * <br>
                     * An example could be: "doSomething( NOTIFICATION, REPETITIONS, java.lang.String )"
                     * where the Scheduler will pass the timer's notification instance, the remaining
                     * repetitions as int and a null to the MBean's doSomething() method which must
                     * have the following signature: doSomething( javax.management.Notification, long,
                     * java.lang.String ).
                     *
                     * @jmx:managed-attribute
                     *
                     * @param pTargetMethod Name of the method to be called optional followed
                     * by method arguments (see above).
                     *
                     * @throws InvalidParameterException If the given value is not of the right
                     * format
                     */
                     public void setTargetMethod( String pTargetMethod )


                    Basically you can specify argument types, but what will be passed in will be null, which isn't much use.

                    In 4.0.3 some changes were made to the scheduling service including a separate config for the argument types versus the argument values. See:

                    http://docs.jboss.org/jbossas/jboss4guide/r3/html/ch10.html#ch10.sched.sect