5 Replies Latest reply on Jun 1, 2006 6:55 AM by Nikola Vanevski

    Deployment of a Schedulable class

    Nikola Vanevski Newbie

      Hi all,

      I have tried to deploy a class that implements Schedulable interface. I created the class MyClass in package mypack, packaged it in a jar and copied it to /jboss/server/default/lib directory.

      I also made the following configuration in scheduler-service.xml :

       <mbean code="org.jboss.varia.scheduler.Scheduler" name=":service=Scheduler">
       <attribute name="SchedulableClass">mypack.MyClass</attribute>
       <attribute name="SchedulableArguments"></attribute>
       <attribute name="SchedulableArgumentTypes"></attribute>
       <attribute name="InitialStartDate">0</attribute>
       <attribute name="SchedulePeriod">10000</attribute>
       <attribute name="InitialRepetitions">-1</attribute>
       <attribute name="StartAtStartup">true</attribute>
       </mbean>
      


      When starting JBoss, it complains that "Given class mypack.MyClass not found".

      Is there something else I should do, so JBoss can "find" the class?

      Thanks in advance,

        • 1. Re: Deployment of a Schedulable class
          Saurabh Sehgal Newbie

          I am getting the exact same error for my Schedulable Class as well. The same class with the same settings in the scheduler XML file works on 4.0.1, but not on 4.0.4

          Try to deploy the same file in 4.0.1SP1 and see what happens.


          • 2. Re: Deployment of a Schedulable class
            Nikola Vanevski Newbie

            Ok, this is the procedure that I'm using : Creating a class Test1 like this :

            package schtest;
            
            import java.util.Date;
            import org.jboss.varia.scheduler.Schedulable;
            
            public class Test1 implements Schedulable {
             private String m_Name;
            
             public Test1(String TheName) {
             m_Name = TheName;
             }
             public void perform(java.util.Date aDate, long aReps) {
             System.out.println("Scheduler tick for "+m_Name);
             }
            
            }
            


            The META-INF/jboss-service.xml is :

            <?xml version="1.0" encoding="UTF-8"?>
            <server>
             <mbean code="org.jboss.varia.scheduler.Scheduler" name="wmSched:service=Scheduler">
             <attribute name="StartAtStartup">true</attribute>
             <attribute name="SchedulableClass">schtest.Test1</attribute>
             <attribute name="SchedulableArguments">TheName</attribute>
             <attribute name="SchedulableArgumentTypes">String</attribute>
             <attribute name="InitialStartDate">NOW</attribute>
             <attribute name="SchedulePeriod">10000</attribute>
             <attribute name="InitialRepetitions">-1</attribute>
             </mbean>
            </server>
            


            The WEB-INF/jboss-web.xml file :
            <?xml version="1.0" encoding="UTF-8"?>
            <!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.3V2//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_3_2.dtd">
            <jboss-web>
             <class-loading java2ClassLoadingCompliance="true" />
             <context-root>wmSched</context-root>
            </jboss-web>
            


            The WEB-INF/web.xml file :
            <?xml version="1.0" encoding="UTF-8"?>
            <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
             <display-name>wmSched</display-name>
            </web-app>
            


            I package all this in a file wmSched.war using Borland JBuilder 2005. When I deploy the .sar file, I get a loooong exception stack trace and following message :

            18:48:38,500 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
            
            --- MBeans waiting for other MBeans ---
            ObjectName: wmSched:service=Scheduler
             State: FAILED
             Reason: org.jboss.deployment.DeploymentException: Exception setting attribute
            javax.management.Attribute: name=SchedulableClass value=schtest.Test1 on mbean wmSched:service=Scheduler; - nested throwable: (java.security.InvalidParameterException: Given class schtest.Test1 is not found)
            
            --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
            ObjectName: wmSched:service=Scheduler
             State: FAILED
             Reason: org.jboss.deployment.DeploymentException: Exception setting attribute javax.management.Attribute: name=SchedulableClass value=schtest.Test1 on mbean wmSched:service=Scheduler; - nested throwable: (java.security.InvalidParameterException: Given class schtest.Test1 is not found)
            


            JBoss is 4.0.3SP1. What am I doing wrong? Please help!!!

            • 3. Re: Deployment of a Schedulable class
              Nikola Vanevski Newbie

              Hmmm.. Feels like talking to myself :) :) :)

              I solved the problem by packaging everything in one .sar package, including all the classes I need. There is now another problem : JNDI-bound datasource can not be seen from within the sar - when I try to perform a lookup for java:comp/env/jdbc/MyDatasrc it fails with env not bound exception. I have everything set up in web.xml and jboss-web.xml, and the lookup works fine outside the sar.

              Is there any workaround for this?

              • 5. Re: Deployment of a Schedulable class
                Nikola Vanevski Newbie

                Cool!! Now everything works just fine.

                Dimitris, if you are in Athens, next time I'm there - you get a beer! :)