6

When I try to start a demo jsvc implementation I get the following error output of jsvc:

jsvc -cp ApacheDeamonDemo.jar -pidfile /mypath/pid.txt -outfile /mypath/log.txt -errfile /mypath/err.log net.example.deamon.DemoDeamon

I get the following error ouput:

Cannot find any VM in Java Home /Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home
Cannot locate JVM library file
Service exit with a return value of 1

Actually the path is correct. Therefore I do not understand why jsvc is telling me this. I'm using a mac.

1
  • I know it's pretty late to comment. Keeping here, if it's gonna help anyone in future. In my case, after a couple of hours of debugging, turned out my java installation is of 32 bit while the system is of 64 bit.
    – acsrujan
    Dec 20, 2017 at 13:36

2 Answers 2

20

Almost five years later, so probably too late to help the original asker, but I had the same problem today trying to run jsvc with open-jdk-11 for AMD64, so this might help someone later.

To diagnose the problem, I ran jsvc with the --debug flag, and that told me that it was choking on trying to find libjvm.so. I ran find /usr/lib/jvm/java-11-openjdk-amd64 -name libjvm.so and found it at /usr/lib/jvm/java-11-openjdk-amd64/lib/server/libjvm.so, but jsvc was looking for it at /usr/lib/jvm/java-11-openjdk-amd64//lib/amd64/server/libjvm.so. So, I did this, and then jscv worked:

sudo mkdir /usr/lib/jvm/java-11-openjdk-amd64/lib/amd64
sudo ln -s /usr/lib/jvm/java-11-openjdk-amd64/lib/server /usr/lib/jvm/java-11-openjdk-amd64/lib/amd64/

It turns out the problem is fixed in later versions of jsvc. I experienced the issue with jsvc version 1.0.6, which is the one you get if you run apt install jsvc on Ubuntu 18.04. After I downloaded the 1.2.0 version commons-daemon src from Apache and compiled jsvc myself, the issue is fixed and I didn't need the symlink anymore.

3
  • 1
    Thanks for this! The problem still exists on Ubuntu 20.04, which ships with jsvc 1.0.15-8 and your workaround still works.
    – sxc731
    Jan 20, 2021 at 20:31
  • I needed this workaround to for starting a UniFi Network Controller on Ubuntu 20.04 with openjdk-14-jre-headless.
    – simlev
    Feb 14, 2021 at 22:54
  • Constant pain, because JSVC is now at 1.3... but there's no PPA for 1.3 Jul 14 at 14:18
-3

Don't know why jsvc would try to locate all the dylib files and load them with dlopen, but apparently, this doesn't work well with Apple's Java release. While fixing jsvc might not be too hard, I just went firing up the JVM myself like so,

export JAVA_HOME=$(/usr/libexec/java_home)
export CATALINA_HOME=/Users/rong/Projects/apache-tomcat-8.0.12
export CATALINA_BASE=$CATALINA_HOME

java \
    -server \
    -classpath $CATALINA_HOME/bin/bootstrap.jar:$CATALINA_HOME/bin/tomcat-juli.jar \
    -Dcatalina.home=$CATALINA_HOME \
    -Dcatalina.base=$CATALINA_BASE \
    -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager \
    -Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties \
    org.apache.catalina.startup.Bootstrap \
    > $CATALINA_BASE/logs/catalina.out \
    2> $CATALINA_BASE/logs/catalina.err

By wrapping this in a bash script and adding a bit of forking, changing UID stuff, you can forget about jsvc completely.

1
  • Sorry, this is not what I'm looking for or what I asked for. I know how to start my program from shell. This is not a solution or answer you are offering here!
    – toom
    Sep 29, 2014 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.