jscv : Cannot locate JVM library file
Asked Answered
A

2

7

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.

Adsorbent answered 16/9, 2014 at 12:5 Comment(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.Digraph
P
22

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.

Procure answered 9/7, 2019 at 16:23 Comment(3)
Thanks for this! The problem still exists on Ubuntu 20.04, which ships with jsvc 1.0.15-8 and your workaround still works.Stucker
I needed this workaround to for starting a UniFi Network Controller on Ubuntu 20.04 with openjdk-14-jre-headless.Reedbuck
Constant pain, because JSVC is now at 1.3... but there's no PPA for 1.3Splenius
R
-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.

Redford answered 29/9, 2014 at 4:59 Comment(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!Adsorbent

© 2022 - 2024 — McMap. All rights reserved.