1 Reply Latest reply on Sep 1, 2008 7:34 AM by amedina

    Dependency problem with Scheduler

    amedina

      Hi,

      i was trying to implement a Scheduler on jboss 4.0.5, but have some problems with the dependency.

      i have added the following code to the scheduler-service.xml:

      <mbean code="org.jboss.varia.scheduler.Scheduler"
       name=":service=Scheduler">
       <attribute name="StartAtStartup">true</attribute>
       <attribute name="SchedulableClass">com.middleware.scheduler.CacheCleaner</attribute>
       <attribute name="InitialStartDate">NOW</attribute>
       <attribute name="SchedulePeriod">30000</attribute>
       <attribute name="InitialRepetitions">-1</attribute>
       <depends>jboss.j2ee:module=myapp-ejb.jar,service=EjbModule</depends>
      </mbean>
      


      The CacheCleaner class is located inside the myapp-ejb.jar, which is deployed within an ear-file.

      the ear-file, as well as the scheduler-service.xml are located in the jboss-deploy-directory, when i start jboss i get the following error message:

      --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
      ObjectName: jboss:service=Scheduler
       State: FAILED
       Reason: org.jboss.deployment.DeploymentException: Exception setting attribute javax.management.Attribute: name=SchedulableClass value=com.middleware.scheduler.CacheCleaner on mbean jboss:service=Scheduler; - nested throwable: (java.security.InvalidParameterException: Given class com.middleware.scheduler.CacheCleaner is not not found)
      


      now, if i do some trivial changes to the scheduler-service.xml(add a whitespace), the code of CacheCleaners perform()-Method gets executed immediately.

      So i guess there is something wrong with the depends attribute, but i don't know what.

      here is the snapshot of the jmx-console:
      jboss.j2ee
      
       * jndiName=ejb/ProgressManager,plugin=pool,service=EJB
       * jndiName=ejb/ProgressManager,service=EJB
       * jndiName=ejb/SessionManager,plugin=cache,service=EJB
       * jndiName=ejb/SessionManager,plugin=pool,service=EJB
       * jndiName=ejb/SessionManager,service=EJB
       * jndiName=ejb/SystemSessionManager,plugin=cache,service=EJB
       * jndiName=ejb/SystemSessionManager,plugin=pool,service=EJB
       * jndiName=ejb/SystemSessionManager,service=EJB
       * module=myapp-ejb.jar,service=EjbModule
       * service=ClientDeployer
       * service=EARDeployer
       * service=EARDeployment,url='myapp.ear'
      


      i've found in the wiki
      http://wiki.jboss.org/wiki/HowCanAnMBeanDependOnASessionBean
      that it is also possible to set the depends attribute directly to the ejb:

      <depends>jboss.j2ee:jndiName=ejb/SessionManager,service=EJB</depends>
      


      unfortunately the result is the same. so what am i doing wrong here?


        • 1. Re: Dependency problem with Scheduler
          amedina

          Ok I have found a working solution for this issue. It is possible to define the scheduler service inside the ear-file.

          just put the following jboss-app.xml together with the scheduler-service.xml inside the META-INF directory of your .ear

          <jboss-app>
           <module>
           <service>META-INF/scheduler-service.xml</service>
           </module>
          </jboss-app>
          


          this works without defining any dependencies in the scheduler-service.xml mbean configuration.

          However, for me it's still a brainteaser why my first approach didn't work...