I am trying to get a Java application to run as a Linux service using jsvc. I found How to convert java program to daemon using jsvc? which could get most of the way from me, but I'm still struggling to get the classpath.
I get the following errors for stderr:
04/19/2013 10:43:18 12233 jsvc.exec error: Cannot find the daemon loader org / apache / commons / daemon / support / DaemonLoader
04/19/2013 10:43:18 12231 Error jsvc.exec: service output with return value 1
It would seem that the runtime cannot find commons-daemon.jar.
My application is structured in such a way that with the application itself in a single jar file with dependencies, including commons-daemon in the lib directory.
- daemon- script.sh
- Myapp.jar
- Library / Public-daemon.jar
- Library / other banks-
Here are the relevant parts of my daemon - script.sh:
LIB_DIR = $ (PWD) / Library / *
CLASS_PATH = $ (PWD) /myapp.jar
$ EXEC -home $ JAVA_EXEC -cp $ CLASS_PATH: $ LIB_DIR -outfile $ LOG_OUT -errfile $ LOG_ERR -pidfile $ PID $ 1 $ CLASS
I tried many variations: the relative path, in particular referring to lib / commons-daemon.jar, without wildcards, etc. Does anyone have any ideas how to make this work properly?
In addition, myapp.jar is a spontaneous bank (mainly for testing purposes, and yes, I still need it to run as a service), so manifest.mf contains the Class-Path and Main-Class attributes. Is there a way to get jsvc to recognize the manifest?