pmoneoingen / myschedule

Automatically exported from code.google.com/p/myschedule
0 stars 0 forks source link

How to use OsCommandJob by loading jobs(xml) #79

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello
I tried to configure OsCommandJob to run some small script.

But I don't know how to configure CommandArguments array in xml file.
I configured like below but it failed with  ClassCastException.
This is my xml.
<?xml version='1.0' encoding='utf-8'?>
<job-scheduling-data version="2.0"
    xmlns="http://www.quartz-scheduler.org/xml/JobSchedulingData"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.quartz-scheduler.org/xml/JobSchedulingData 
    http://www.quartz-scheduler.org/xml/job_scheduling_data_2_0.xsd">
    <schedule>
        <job>
            <name>HelloWorld</name>
            <group>example</group>
            <description>
            *comment    : test oscommandjob
            </description>
            <job-class>myschedule.quartz.extra.job.OsCommandJob</job-class>
            <job-data-map>
                <entry>
                    <key>CommandArguments</key>
                    <value>/home/skiver/git/repository/Test/hello.sh</value>
                </entry>
                <entry>
                    <key>Timeout</key>
                    <value>0</value>
                </entry>

            </job-data-map>
        </job>
        <trigger>
            <cron>
                <name>HelloWorldTrigger</name>
                <group>example</group>
                <job-name>HelloWorld</job-name>
                <job-group>example</job-group>
                <cron-expression>0 5 * * * ?</cron-expression>
            </cron>
        </trigger>

    </schedule>
</job-scheduling-data>

This is error message.
java.lang.ClassCastException: java.lang.String cannot be cast to 
[Ljava.lang.String;
    at myschedule.quartz.extra.job.OsCommandJob.execute(OsCommandJob.java:67)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:557)
[10:04:20][ERROR](JobRunShell.java:222) - Job example.HelloWorld threw an 
unhandled Exception: 
java.lang.ClassCastException: java.lang.String cannot be cast to 
[Ljava.lang.String;
    at myschedule.quartz.extra.job.OsCommandJob.execute(OsCommandJob.java:67)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:557)
[10:04:20][INFO ](JdbcSchedulerHistoryPlugin.java:183) - 2012-03-28

Best regards

Original issue reported on code.google.com by james.yo...@gmail.com on 28 Mar 2012 at 8:08

GoogleCodeExporter commented 9 years ago
Hello James,

The current OsCommandJob expect you create that in code only. We will have to 
enhance it to accept single string before you can use the XML loader.

I will mark this as enhancement to track it.

Original comment by saltnlight5 on 28 Mar 2012 at 9:56

GoogleCodeExporter commented 9 years ago
Just committed this change. Give the snapshot a try.

Original comment by saltnlight5 on 28 Mar 2012 at 10:59

GoogleCodeExporter commented 9 years ago

Original comment by saltnlight5 on 1 Jun 2012 at 12:05

GoogleCodeExporter commented 9 years ago

Original comment by saltnlight5 on 1 Jun 2012 at 12:05