Cron Throws "Exception in thread "main" java.util.zip.ZipException: No such file or directory"

Hi,

I have scheduled a cron job to run at 8:00 o'clock every night without fail.  Here is the crontab:

# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (legacy.cron installed on Fri Nov 26 09:15:21 2004)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
00 20 * * * /opt/myApp/runApplication.sh

When the application is run directly (not through Cron) it works fine.  Its just a shell script that loads up a java application:

((/opt/myApp/runApplication.sh))

#!/bin/bash
/opt/java/j2sdk/bin/java -Xbootclasspath/a:"/opt/myApp/resource.jar" -jar lib/myJar.jar -config myConfig.conf 2>&1 | tee /opt/myApp/logfile.log

However, when run through Cron, I receive the following error in the log file:

Exception in thread "main" java.util.zip.ZipException: No such file or directory
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(ZipFile.java:112)
        at java.util.jar.JarFile.<init>(JarFile.java:117)
        at java.util.jar.JarFile.<init>(JarFile.java:55)


This is only when the app is run through Cron.  As far as I am aware, the application doesn't call any zip functions, but I am quite new to Java and I could be wrong.

Any help would be brilliant, thanks!
garry_mAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

owensleftfootCommented:
Its probably a path problem. After you have run it from the command line, run "set". One of the lines will show you your current path. Copy this line and insert the following in your runApplication.sh after #!/bin/bash

export PATH=line-copied-from-set-command
0
wesly_chenCommented:
>  the application is run directly (not through Cron) it works fine
The environment variable setting issue. Cron doesn't have your environment variable setting to tun the application.
Set the environment variables in /opt/myApp/runApplication.sh
or add ". <path to your home dir>/.bashrc" at the second line of /opt/myApp/runApplication.sh.

Wesly
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
garry_mAuthor Commented:
Thanks guys!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.