4 Replies Latest reply on Jul 18, 2005 1:50 AM by mcaughey

    Schedular Help - Server Starting cannont find Schedular

    mcaughey

      I have a Class which implements Schedulable, it uses Hibernate to check some tables. It's real simple at this point. The problem however occurs when the Server starts up it cannot find the Scheduler. The class is in the scheduler-plugin.jar in the lib directory. Its a standard jar with JBoss 4.0.2.

      Here's what I put in the jboss-service.xml


      true
      com.tables.events.CheckForTablesTask
      101
      int
      10000
      -1


      Here's the error I'm getting:

      00:38:46,718 ERROR [MainDeployer] could not create deployment: file:/S:/jboss-4.0.2/server/default/conf/jboss-service.xml
      org.jboss.deployment.DeploymentException: No ClassLoaders found for: org.jboss.varia.schedular.Schedular; - nested throwable: (java.lang.ClassNotFoundException: No ClassLoaders found for: org.jboss.varia.schedular.Schedular)
      at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java:143)
      at org.jboss.system.ServiceController.install(ServiceController.java:202)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy4.install(Unknown Source)
      ... there more, but i cut it out.


      Here's my Scheduled Event Class, for what it's worth:

      public class CheckForTablesTask implements Schedulable {
      private static Logger logger = null;
      private int serverId = 0;

      public CheckForTablesTask(int serverId) {
      this.serverId = serverId;
      }

      public void perform(Date date, long param) {
      if (logger == null) {
      logger = Logger.getLogger(CheckForTablesTask.class);
      }

      logger.debug("Server ["+serverId+"] checking for new tables");

      StringBuffer queryStr = new StringBuffer();
      queryStr.append("from Table as t where t.serverId = ");
      queryStr.append(serverId);
      queryStr.append("and t.topicCreated = 0");

      try {
      Session session = SessionManager.currentSession();
      Iterator itt = session.createQuery(queryStr.toString()).iterate();

      Table table;
      while(itt.hasNext()){
      table = (Table)itt.next();
      logger.debug("Server ["+serverId+"] new table, name = "+ table.getName());

      // Create topic

      // Change Status
      table.setTopiccreated(new Byte((byte)1));
      table.setStatus(Tablestatus.REGISTERING);
      }
      session.flush();
      } catch (HibernateException he) {
      logger.error(CheckForTablesTask.class.getName() + ": server["
      + serverId + "] threw HibernateException : ", he);
      } finally {
      try {
      SessionManager.closeSession();
      } catch (HibernateException he) {
      // do nothing
      }
      }
      }
      }

      I have in my jar file, this class, the classes required for Hibernate distribution and my hibernate classes and mappings. I placed this file in the lib directory under the server/default/lib directory. The scheduler-plugin.jar is there as well.

      Why doesn't the server see the scheduler-plugin.jar?

      Am I placing the mbean definition in the right place, by placing it in the jboss-service.xml?

      Am I doing the right thing by placing the CheckTablesTask, the Hibernate Dist and my hibernate classes in the server/defalut/lib directory as a jar file?

      Thanks,
      Michael

        • 1. Re: Schedular Help - Server Starting cannont find Schedular
          mcaughey

          Here's the MBEAN again since I forgot to disable HTML


          true
          com.tables.events.CheckForTablesTask
          101
          int
          10000
          -1

          • 2. Re: Schedular Help - Server Starting cannont find Schedular
            mcaughey

             

             <mbean code="org.jboss.varia.schedular.Schedular" name="TableServer:service=TableChecker">
             <attribute name="StartAtStartup">true</attribute>
             <attribute name="SchedulableClass">com.tables.events.CheckForTablesTask</attribute>
             <attribute name="SchedulableArguments">101</attribute>
             <attribute name="SchedulableArgumentTypes">int</attribute>
             <attribute name="SchedulePeriod">10000</attribute>
             <attribute name="InitialRepetitions">-1</attribute>
             </mbean>
            
            


            • 3. Re: Schedular Help - Server Starting cannont find Schedular
              mcaughey

              Here's the class

              public class CheckForTablesTask implements Schedulable {
               private static Logger logger = null;
               private int serverId = 0;
              
               public CheckForTablesTask(int serverId) {
               this.serverId = serverId;
               }
              
               public void perform(Date date, long param) {
               if (logger == null) {
               logger = Logger.getLogger(CheckForTablesTask.class);
               }
              
               logger.debug("Server ["+serverId+"] checking for new tables");
              
               StringBuffer queryStr = new StringBuffer();
               queryStr.append("from Table as t where t.serverId = ");
               queryStr.append(serverId);
               queryStr.append("and t.topicCreated = 0");
              
               try {
               Session session = SessionManager.currentSession();
               Iterator itt = session.createQuery(queryStr.toString()).iterate();
              
               Table table;
               while(itt.hasNext()){
               table = (Table)itt.next();
               logger.debug("Server ["+serverId+"] new table, name = "+ table.getName());
              
               // Create topic
              
               // Change Status
               table.setTopiccreated(new Byte((byte)1));
               table.setStatus(Tablestatus.REGISTERING);
               }
               session.flush();
               } catch (HibernateException he) {
               logger.error(CheckForTablesTask.class.getName() + ": server["
               + serverId + "] threw HibernateException : ", he);
               } finally {
               try {
               SessionManager.closeSession();
               } catch (HibernateException he) {
               // do nothing
               }
               }
               }
              }
              


              • 4. Re: Schedular Help - Server Starting cannont find Schedular
                mcaughey

                I figured it out, I'm a bad speller. I had Schedular rather than Scheduler. Note the A and the E.


                I ended up deploying this as a SAR.

                I also left out the InitialStartDate attribute on accident, all i got was a NullPointerException at line 318 of the Scheduler class. I figured that out by looking at the JBOSS source.

                It does now work.

                -Michael