JBoss Scheduler wie Publizieren bitte bitte helfen

tovbiwankenobi

Grünschnabel
Hi Leure,
ich versuch nun seid 10 Tagen und Nächten einen einfachen Scheduler unter JBoss zum laufen zu bringen. Ich benutze Eclipse mit der der JBossIDE 2 und JBoss 4. Also folgendes habe ich bereits hinbekommen:
Eine Scheduler-service.xml mit folgendem Inhalt:
Code:
 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE server>
<!-- $Id: scheduler-service.xml,v 1.6 2004/09/02 05:37:26 telrod Exp $ -->

<server>
<mbean code="org.jboss.varia.scheduler.Scheduler"
	 name="ownm:service=Scheduler">
    <attribute name="StartAtStartup">true</attribute>
    <attribute name="SchedulableClass">de.test.SchedulerTest</attribute>
    <attribute name="SchedulableArguments">Schedulabe Test,12345</attribute>
    <attribute name="SchedulableArgumentTypes">java.lang.String,int</attribute>
    <attribute name="InitialStartDate">0</attribute>
    <attribute name="SchedulePeriod">10000</attribute>
    <attribute name="InitialRepetitions">-1</attribute>
    <depends>
	<mbean code="javax.management.timer.Timer"
	name="jboss:service=Timer"/> 
	</depends>
  </mbean>
</server>
Diese XML liegt im richtigen Verzeichnis und wird auch geladen. Leider bekomme ich immer wieder den Fehler
Code:
org.jboss.deployment.DeploymentException: Unexpected error during load of: org.jboss.varia.scheduler.Scheduler, msg=org/jboss/system/ServiceMBean; - nested throwable: (java.lang.ClassNotFoundException: Unexpected error during load of: org.jboss.varia.scheduler.Scheduler, msg=org/jboss/system/ServiceMBean)

Es scheint so als würde er meine Scheduler Class (de.test.SchedulerTest) nicht finden. Wie muß ich die wohin publishen damit JBoss sie finden und laden kann?
Vielen dank für eure Hilfe.
 
Hallo,

Unser zu Schedulender Task:
Java:
/**
 * 
 */
package de.tutorials.training.jboss.scheduler;

import java.util.Date;

import org.jboss.varia.scheduler.Schedulable;

/**
 * @author Tom
 * 
 */
public class SchedulingExample implements Schedulable {

    String property1;
    String property2;
    long property3;

    public SchedulingExample(String property1, String property2, long property3) {
        super();
        this.property1 = property1;
        this.property2 = property2;
        this.property3 = property3;
    }

    @Override
    public void perform(Date arg0, long arg1) {
        System.out.println("Scheduling: " + getClass() + " at: " + arg0
                + " arg1: " + arg1 + " p1:" + property1 + " p2: " + property2
                + " p3: " + property3);
    }

    public String getProperty1() {
        return property1;
    }

    public void setProperty1(String property1) {
        this.property1 = property1;
    }

    public String getProperty2() {
        return property2;
    }

    public void setProperty2(String property2) {
        this.property2 = property2;
    }

    public long getProperty3() {
        return property3;
    }

    public void setProperty3(long property3) {
        this.property3 = property3;
    }

}

Als jar exportieren nach %JBOSS_HOME%/server/%SERVER_CONFIG%/lib

Eintrag in scheduler-service.xml
XML:
    <mbean code="org.jboss.varia.scheduler.Scheduler"
     name="de.tutorials:service=Scheduler">
    <attribute name="StartAtStartup">true</attribute>
    <attribute name="SchedulableClass">de.tutorials.training.jboss.scheduler.SchedulingExample</attribute>
    <attribute name="SchedulableArguments">Gugu,Gaga,12345</attribute>
    <attribute name="SchedulableArgumentTypes">java.lang.String,java.lang.String,long</attribute>
    <attribute name="InitialStartDate">0</attribute>
    <attribute name="SchedulePeriod">10000</attribute>
    <attribute name="InitialRepetitions">-1</attribute>
    <attribute name="FixedRate">true</attribute>    
  </mbean>

Ich starte den Server in der All Konfiguration:

Ausgabe:
Code:
...
21:02:16,781 INFO  [TomcatDeployer] deploy, ctxPath=/jmx-console, warUrl=.../deploy/jmx-console.war/
21:02:17,125 INFO  [Http11BaseProtocol] Starting Coyote HTTP/1.1 on http-0.0.0.0-8080
21:02:17,266 INFO  [ChannelSocket] JK: ajp13 listening on /0.0.0.0:8009
21:02:17,297 INFO  [JkMain] Jk running ID=0 time=0/78  config=null
21:02:17,312 INFO  [Server] JBoss (MX MicroKernel) [4.0.5.GA (build: CVSTag=Branch_4_0 date=200610162339)] Started in 28s:140ms
21:02:20,000 INFO  [STDOUT] Scheduling: class de.tutorials.training.jboss.scheduler.SchedulingExample at: Mon May 21 21:02:20 CEST 2007 arg1: -1 p1:Gugu p2: Gaga p3: 12345
21:02:30,000 INFO  [STDOUT] Scheduling: class de.tutorials.training.jboss.scheduler.SchedulingExample at: Mon May 21 21:02:30 CEST 2007 arg1: -1 p1:Gugu p2: Gaga p3: 12345
21:02:40,000 INFO  [STDOUT] Scheduling: class de.tutorials.training.jboss.scheduler.SchedulingExample at: Mon May 21 21:02:40 CEST 2007 arg1: -1 p1:Gugu p2: Gaga p3: 12345
21:02:50,000 INFO  [STDOUT] Scheduling: class de.tutorials.training.jboss.scheduler.SchedulingExample at: Mon May 21 21:02:50 CEST 2007 arg1: -1 p1:Gugu p2: Gaga p3: 12345
21:03:00,000 INFO  [STDOUT] Scheduling: class de.tutorials.training.jboss.scheduler.SchedulingExample at: Mon May 21 21:03:00 CEST 2007 arg1: -1 p1:Gugu p2: Gaga p3: 12345
21:03:10,000 INFO  [STDOUT] Scheduling: class de.tutorials.training.jboss.scheduler.SchedulingExample at: Mon May 21 21:03:10 CEST 2007 arg1: -1 p1:Gugu p2: Gaga p3: 12345
21:03:20,000 INFO  [STDOUT] Scheduling: class de.tutorials.training.jboss.scheduler.SchedulingExample at: Mon May 21 21:03:20 CEST 2007 arg1: -1 p1:Gugu p2: Gaga p3: 12345

In der JMX-Console siehst du dann den Scheduler im Namespace: de.tutorials

Gruß Tom
 

Anhänge

  • de.tutorials.training.jboss.scheduler.jar
    1,9 KB · Aufrufe: 108
  • jmx-console-scheduler.jpg
    jmx-console-scheduler.jpg
    58,6 KB · Aufrufe: 242
Zuletzt bearbeitet von einem Moderator:
Vielen Dank für deine Antwort. Leider funtzt das auch nicht. Aber ich glaube das liegt daran das er die Jar nicht lädt. Müssen die %JBOSS_HOME%, %Server% und %SERVER_CONFIG% als umgebungsvariablen gesetzt sein? Wenn ja wo müssen die genau hin?
 
Wie kann ich im scheduler-service.xml angeben wo meine aufzurufende Klasse liegt wenn sie in einem EAR File ist? Hatte sie vorher in einem Jar im Deploy Verzeichnis und konnte sie korrekt folgendermassen angeben:
<classpath codebase="deploy" archives="casex-base-int.jar"/>

Ich habe das Jar nun in ein EAR gepackt und ins deploy Verzeichnis kopiert. Nun weiss ich nicht wie ich den classpath Tag anpassen muss.

Kann mir da jemand helfen?

Vielen Dank
 
Hallo Thomas,

ich habe eine Frage zur scheduler-service.xml
Es gibt zwei Möglichkeiten für diese Datei:

To setup a Scheduler in a service.xml file using a Schedulable class add this code snippet and adjust it to your needs:

<mbean code="org.jboss.util.Scheduler" name=":service=Scheduler">
<attribute name="SchedulableClass">org.jboss.util.Scheduler$SchedulableExample</attribute>
<attribute name="SchedulableArguments">Schedulabe Test,12345</attribute>
<attribute name="SchedulableArgumentTypes">java.lang.String,int</attribute>
<attribute name="InitialStartDate">0</attribute>
<attribute name="SchedulePeriod">10000</attribute>
<attribute name="InitialRepetitions">-1</attribute>
<attribute name="StartAtStartup">true</attribute>
</mbean>


To setup a Scheduler in a service.xml file using a Schedulable MBean add this code snippet and adjust it to your needs:

<mbean code="org.jboss.util.SchedulableExample" name="jboss:type=example,name=schedulable">
</mbean>
<mbean code="org.jboss.util.Scheduler" name="jboss:service=Scheduler">
<attribute name="StartAtStartup">true</attribute>
<attribute name="SchedulableMBean">jboss:type=example,name=schedulable</attribute>
<attribute name="SchedulableMBeanMethod">hit( NOTIFICATION, DATE, REPETITIONS, SCHEDULER_NAME, java.lang.String )</attribute>
<attribute name="InitialStartDate">NOW</attribute>
<attribute name="SchedulePeriod">10000</attribute>
<attribute name="InitialRepetitions">10</attribute>
</mbean>

Du benutzt die erste und was ist der Vorteil von Mbeans?
Danke.
 
Zurück