سؤال

Launching the jar via a java -cp command in an shell scrip eg: RunFileConverter.sh file on linux works without a problem. But, when I try to execute the script via 'crontab -e' it gives me a ClassFormatError.

The jar was compiled on Win7 with the Java 6 jdk (latest) and the java version on the (redhat) linux server is also JRE 6 (1.6.0_29).

owner of the files is pipe, and the crontab is launched via same user.

Contents of the RunFileConverter.sh:

java -cp /home/pipe/Custom/cbs/:/home/pipe/Custom/cbs/FileConverter.jar fileconverter.Launcher

Filestructure (/home/pipe/Custom/cbs/): lib/somelib.jar FileConverter.jar FileConverter.properties RunFileConverter.sh fileconverter.log

Stripped down Launching class file:

package fileconverter;

import java.io.*;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.logging.FileHandler;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Launcher {

    // logger
    public final static Logger LOGGER = Logger.getLogger(FileConverter.LOGFILE);

    /**
     * Main class
     * @param args
     * @throws FileNotFoundException 
     */
    public static void main(String[] args) throws FileNotFoundException {

        // logger handlers, properties etc ...
        Handler fileHandler;
        // ...


        // create converters
        FileConverter requestConverter = new RequestFileConverter();
        FileConverter exportConverter = new ExportFileConverter();

        // start ya conversions, aarrr mate
        requestConverter.run();
        exportConverter.run();

    }
}

crontab-e

*/5 * * * * /home/pipe/Custom/cbs/RunFileConverter.sh

I have no idea what the error might be

هل كانت مفيدة؟

المحلول

Most likely cron does have different (older) version of java in path.

What does it say if you execute java -version via cron?

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top