Cron job problem

Associate
Joined
26 Oct 2003
Posts
1,107
Hi,

I have a java application which parses some data from the BBC News website and inserts in into a database for my final year project. The application works fine, however I need to make this run automatically at set intervals so I've setup a crontab on one of the universitys UNIX servers to run the java app automatically 4 times throughout the day.

The command I need to run is,
Code:
java -jar [B]-Dorg.xml.sax.driver=org.apache.crimson.parser.XMLReaderImpl[/B] /home/hudson/ug/d53s9b/project/rss2sql.jar

I've setup the crontab to run this command 4 times a day; which it does... however for the java app to run correctly it requires the additional -D parameter (in bold above). However, when the crontab runs it doesn't seem to take account of the -D parameter; however when I run the command at the shell it works fine :confused:.

The cron job output has lots of...
SAX Exception: SAX2 driver class org.apache.crimson.parser.XMLReaderImpl not found

Anyone got any ideas on how to fix this? Is it possible to put the java command within a shell script (although I don't know anything about this), then execute that?

Thanks,
Alex
 
bigred said:
Hi,

I have a java application which parses some data from the BBC News website and inserts in into a database for my final year project. The application works fine, however I need to make this run automatically at set intervals so I've setup a crontab on one of the universitys UNIX servers to run the java app automatically 4 times throughout the day.

The command I need to run is,
Code:
java -jar [B]-Dorg.xml.sax.driver=org.apache.crimson.parser.XMLReaderImpl[/B] /home/hudson/ug/d53s9b/project/rss2sql.jar

I've setup the crontab to run this command 4 times a day; which it does... however for the java app to run correctly it requires the additional -D parameter (in bold above). However, when the crontab runs it doesn't seem to take account of the -D parameter; however when I run the command at the shell it works fine :confused:.

The cron job output has lots of...
SAX Exception: SAX2 driver class org.apache.crimson.parser.XMLReaderImpl not found

Anyone got any ideas on how to fix this? Is it possible to put the java command within a shell script (although I don't know anything about this), then execute that?

Thanks,
Alex
Yes definatley. Try that.
 
Creating a shell script works (and it's now also much easier to run :)) however the same error occurs when executing the shell script in a cron job :(

I think it might be something to do with the classpath... and when the cron job runs it doesn't know where to find the apache jar's?
 
Having looked at your error try adding the classpath to the path of the user that runs the crontab job.

Edit: basically what you said above :o :o
 
aah, fixed it :D

When executed a cron, it was using a different version of Java (GNU libgcj) instead of the proper Java. I just had to replace 'java' with the full path to it.

Thanks for your help,
Alex
 
Back
Top Bottom