[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


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

Posted on 2004-11-26
Medium Priority
Last Modified: 2013-12-15

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/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!
Question by:garry_m
LVL 17

Assisted Solution

owensleftfoot earned 200 total points
ID: 12680016
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
LVL 38

Accepted Solution

wesly_chen earned 200 total points
ID: 12682798
>  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.


Author Comment

ID: 13789881
Thanks guys!

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Often times it's very very easy to extend a volume on a Linux instance in AWS, but impossible to shrink it. I wanted to contribute to the experts-exchange community a way of providing a procedure that works on an AWS instance. It can also be used on…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month20 days, 4 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question