aspose file tools*
The moose likes Linux / UNIX and the fly likes Exception initiating Driver in Cron Job Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Exception initiating Driver in Cron Job" Watch "Exception initiating Driver in Cron Job" New topic
Author

Exception initiating Driver in Cron Job

Steven Ho
Greenhorn

Joined: Jan 16, 2003
Posts: 15
Hello,
I am trying to run a Java application weekly that update database, and I am using Cron Job to do so.
The problem is I am trying to instantiate the Driver using

and got exception as output "com.mysql.jdbc.Driver" others are stack trace...
I have developed database application on the same environment over many times, this problem only occured now because I am using Cron Job.
I tried to set the class path to the jar file without success.
Does anyone have any experience similar to this, and have found a solution?
Please help. Thanks.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Cron jobs don't get the same environment variables as you do when you log in; the precise details differ depending on your OS and shell, but basically, what you need to do is have the cron job invoke a shell script. In that shell script, either define things like the CLASSPATH, the PATH, etc, directly, or source in the init files that define them directly (i.e., "source ~/.bashrc", for example). Don't have the cron job assume anything about the environment.


[Jess in Action][AskingGoodQuestions]
Steven Ho
Greenhorn

Joined: Jan 16, 2003
Posts: 15
I have added the entire complete classpath
CLASSPATH=.:/usr/local/jdk/lib/classes.zip:/usr/local/jakarta/lib/activation.jar:/usr/local/jakarta/lib/cimapi.jar:/usr/local/jakarta/lib/client.jar:/usr/local/jakarta/lib/crimson.jar:/usr/local/jakarta/lib/dom4j.jar:/usr/local/jakarta/lib/fscontext.jar:/usr/local/jakarta/lib/imap.jar:/usr/local/jakarta/lib/jaas.jar:/usr/local/jakarta/lib/jaxm-client.jar:/usr/local/jakarta/lib/jaxm.jar:/usr/local/jakarta/lib/jaxr-api.jar:/usr/local/jakarta/lib/jaxr-apidoc.jar:/usr/local/jakarta/lib/jaxr-browser. jar:/usr/local/jakarta/lib/jaxr-ri.jar:/usr/local/jakarta/lib/jaxrpc-api.jar:/usr/local/jakarta/lib/jaxrpc-ri.jar:/usr/local/jakarta/lib/jcert.jar:/usr/local/jakarta/lib/jdbc2_0-stdext.jar:/usr/local/jakarta/lib/jmx_remoting.jar:/usr/local/jakarta/lib/jmxgrinder.jar:/usr/local/jakarta/lib/jmxri.jar:/usr/local/jakarta/lib/jmxtools.jar:/usr/local/jakarta/lib/jndi.jar:/usr/local/jakarta/lib/jnet.jar:/usr/local/jakarta/lib/jsse.jar:/usr/local/jakarta/lib/jta.jar:/usr/local/jakarta/lib/ldap.jar:/usr/ local/jakarta/lib/log4j.jar:/usr/local/jakarta/lib/mail.jar:/usr/local/jakarta/lib/mailapi.jar:/usr/local/jakarta/lib/mm.mysql-2.0.11-bin.jar:/usr/local/jakarta/lib/mof2mbean.jar:/usr/local/jakarta/lib/mofcomp.jar:/usr/local/jakarta/lib/pop3.jar:/usr/local/jakarta/lib/providerutil.jar:/usr/local/jakarta/lib/relaxer.jar:/usr/local/jakarta/lib/smtp.jar:/usr/local/jakarta/lib/soap.jar:/usr/local/jakarta/lib/tyrex-0.9.7.0.jar:/usr/local/jakarta/lib/xalan.jar:/usr/local/jakarta/lib/xerces.jar:/usr/lo cal/jakarta/lib/xercesSamples.jar:/usr/local/jakarta/lib/xml.jar
The exception is gone, but no output either
Anyway thanks for the help. Have a nice day.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

You should pipe the output to a file.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception initiating Driver in Cron Job