Skip to main content

Quartz Scheduler support for Unix Shell Script execution - Java.lang.Exception at Process.exec

No replies
ajammalamadaka
Offline
Joined: 2013-08-09
Points: 0

Hi All,

Iam trying to create a Quartz project to schedule a distributed application for High Volume Ebcdic data conversion .
Basically the EBCDIC data conversion and manipulation program is a C++ program ,which takes in a set of input EBCDIC files and processes the EBCDIC data and writes to output files after internal business logic implementation.

We were able to create the executable for the C++ program . Since it has to be scheduled as a bihourly process, we have created a Linux shell script for the same, where we setup the EBCDIC file configurations, and then invoke the C++ executable.

In order to implement a scheduler , we have opted for Quartz Scheduler implementation.

Just to give you an idea of the volume (the input EBCDIC files run into Millions of records ).
So when we implement the test Quartz setup with a simple Shell script, (which basically just echoes "Hello World" ) the scheduler component is working fine.

However, when we invoke the shell script for the core business logic, iam getting a

java.lang.Exception: Execution failed!
at com.wcc.WCCScriptProcessor.executeScript(WCCScriptProcessor.java:27)
at com.wcc.batch.WCCBalIntMainBatch.execute(WCCBalIntMainBatch.java:25)
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:557)
Caused by: java.lang.Exception: Execution failed for command :sh /home/offline/wcc-balancing/scripts/wcc_balancing.sh
at com.wcc.WCCScriptProcessor.executeScript(WCCScriptProcessor.java:18)

Here is my quartz properties file

#============================================================================
# Configure Main Scheduler Properties
#============================================================================

org.quartz.scheduler.instanceName=TestScheduler
org.quartz.scheduler.instanceId=AUTO

org.quartz.scheduler.skipUpdateCheck=true

#============================================================================
# Configure ThreadPool
#============================================================================

org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount=1
org.quartz.threadPool.threadPriority=5

#============================================================================
# Configure JobStore
#============================================================================

#org.quartz.jobStore.misfireThreshold = 60000
#org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore

#============================================================================
# Configure Plugins
#============================================================================

org.quartz.plugin.triggHistory.class=org.quartz.plugins.history.LoggingJobHistoryPlugin

org.quartz.plugin.jobInitializer.class=org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin
org.quartz.plugin.jobInitializer.fileNames=quartz_data.xml
org.quartz.plugin.jobInitializer.failOnFileNotFound=true
org.quartz.plugin.jobInitializer.scanInterval=10
org.quartz.plugin.jobInitializer.wrapInUserTransaction=false
~
~
~
~

And here is the quartz job config

<?xml version="1.0" encoding="UTF-8"?>
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_1_8.xsd"
version="1.8">

* *

true

false



WCC2hrJobName
com.wcc.batch.WCCBalIntMainBatch


WCCEODJobName
com.wcc.batch.WCCBalEODMainBatch


WCCHourlyJobTrigger
WCC2hrJobName

0/5 * * * * ?



WCCDailyJobTrigger
WCCEODJobName

0/5 * * * * ?



Also, here is a screenshot of the shell script being existent in the Linux path tht is mentioned in my code :

/home/projoffline/wcc-balancing/scripts
-bash-4.1$ ls
wcc_balancing.sh

And here is my job implementor

public class WCCBalEODMainBatch implements Job {
@Override
public void execute(JobExecutionContext arg0) throws JobExecutionException {
System.out.println("Running WCCBalEODMainBatch now :: "+new java.util.Date());
String command = "sh "+WCCScriptProperties.getProperty("WCCBAL_SH");//"sh /home/projoffline/wcc-balancing/scripts/wcc_balancing.sh";

WCCScriptProcessor wccScriptProcessor = new WCCScriptProcessor();
wccScriptProcessor.setInputCmd(command);
try {
wccScriptProcessor.executeScript();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

Any ideas on why iam getting an exception please. Please Help.

Thanks
Aruna