How can I get Jsvc to find the DaemonLoader?

13,035

You probably found the solution by now, but just in case someone stumble over this in the future, what I had missed in mine is that current directory defaults to '/', so you have to specify it if you want to use relative paths.

sudo jsvc -jvm server -cwd /path/to/my/daemon/ -cp commons-daemon-1.0.15.jar:./api-monitor.jar ApiMonitorDaemon

Note: my OS is ubuntu 12.10

Share:
13,035
johnnieb
Author by

johnnieb

John Boyer hails from Seattle, WA. He’s a mobile software entrepreneur, developer, and product manager with twenty years of experience in the software industry. He's the president and cofounder of Rodax Software, which develops cloud-based productivity apps for mobile devices such as Skedi Family Calendar for iOS. Follow him on Twitter, johnnieb99 SOreadytohelp

Updated on June 04, 2022

Comments

  • johnnieb
    johnnieb almost 2 years

    I have the commons-daemon-x.jar in the classpath. The Jsvc is successfully launching the Java VM. But jsvc is reporting that it cannot find the daemon loader class even though it is in the classpath.

    Does anyone know how to solve this problem? I’m running Mac OS X 10.8.3. Thanks.

    Here's an excerpt of the jsvc debug output:

    ...    
    +-- DUMPING JAVA VM CREATION ARGUMENTS -----------------
    | Version:                       0x010004
    | Ignore Unrecognized Arguments: False
    | Extra options:                 1
    |   "-Djava.class.path=commons-daemon-1.0.15.jar:./api-monitor.jar" (0x00000000)
    +———————————————————————————
    ...
    Java VM created successfully
    Cannot find daemon loader org/apache/commons/daemon/support/DaemonLoader
    java_init failed
    Service exit with a return value of 1
    ...
    

    Here’s the full debug output if it helps:

    sudo jsvc -jvm server -debug -cp commons-daemon-1.0.15.jar:./api-monitor.jar ApiMonitorDaemon
    
    +-- DUMPING PARSED COMMAND LINE ARGUMENTS --------------
    | Detach:          True
    | Show Version:    No
    | Show Help:       No
    | Check Only:      Disabled
    | Stop:            False
    | Wait:            0
    | Run as service:  No
    | Install service: No
    | Remove service:  No
    | JVM Name:        "server"
    | Java Home:       "null"
    | PID File:        "/var/run/jsvc.pid"
    | User Name:       "null"
    | Extra Options:   1
    |   "-Djava.class.path=commons-daemon-1.0.15.jar:./api-monitor.jar"
    | Class Invoked:   "ApiMonitorDaemon"
    | Class Arguments: 0
    +-------------------------------------------------------
    Home not specified on command line, using environment
    Home not on command line or in environment, searching
    Attempting to locate Java Home in /System/Library/Frameworks/JavaVM.framework/Home
    Attempting to locate VM configuration file /System/Library/Frameworks/JavaVM.framework/Home/jre/lib/jvm.cfg
    Attempting to locate VM configuration file /System/Library/Frameworks/JavaVM.framework/Home/lib/jvm.cfg
    Found VM configuration file at /System/Library/Frameworks/JavaVM.framework/Home/lib/jvm.cfg
    Found VM client definition in configuration
    Checking library /System/Library/Frameworks/JavaVM.framework/Home/../Libraries/libclient.dylib
    Found VM jvm definition in configuration
    Checking library /System/Library/Frameworks/JavaVM.framework/Home/../Libraries/libjvm.dylib
    Found VM hotspot definition in configuration
    Checking library /System/Library/Frameworks/JavaVM.framework/Home/../Libraries/libhotspot.dylib
    Found VM server definition in configuration
    Checking library /System/Library/Frameworks/JavaVM.framework/Home/../Libraries/libserver.dylib
    Found VM classic definition in configuration
    Checking library /System/Library/Frameworks/JavaVM.framework/Home/../Libraries/libclassic.dylib
    Cannot locate library for VM classic (skipping)
    Java Home located in /System/Library/Frameworks/JavaVM.framework/Home
    +-- DUMPING JAVA HOME STRUCTURE ------------------------
    | Java Home:       "/System/Library/Frameworks/JavaVM.framework/Home"
    | Java VM Config.: "/System/Library/Frameworks/JavaVM.framework/Home/lib/jvm.cfg"
    | Found JVMs:      4
    | JVM Name:        "client"
    |                  "/System/Library/Frameworks/JavaVM.framework/Home/../Libraries/libclient.dylib"
    | JVM Name:        "jvm"
    |                  "/System/Library/Frameworks/JavaVM.framework/Home/../Libraries/libjvm.dylib"
    | JVM Name:        "hotspot"
    |                  "/System/Library/Frameworks/JavaVM.framework/Home/../Libraries/libhotspot.dylib"
    | JVM Name:        "server"
    |                  "/System/Library/Frameworks/JavaVM.framework/Home/../Libraries/libserver.dylib"
    +-------------------------------------------------------
    my-server:Applications developer$ redirecting stdout to /dev/null and stderr to /dev/null
    Switching umask back to 022 from 077
    Using specific JVM in /System/Library/Frameworks/JavaVM.framework/Home/../Libraries/libserver.dylib
    Attemtping to load library /System/Library/Frameworks/JavaVM.framework/Home/../Libraries/libserver.dylib
    JVM library /System/Library/Frameworks/JavaVM.framework/Home/../Libraries/libserver.dylib loaded
    Attemtping to load library /System/Library/Frameworks/JavaVM.framework/Home/../Libraries/libverify.dylib
    Shell library /System/Library/Frameworks/JavaVM.framework/Home/../Libraries/libverify.dylib loaded
    JVM library entry point found (0x02A49762)
    +-- DUMPING JAVA VM CREATION ARGUMENTS -----------------
    | Version:                       0x010004
    | Ignore Unrecognized Arguments: False
    | Extra options:                 1
    |   "-Djava.class.path=commons-daemon-1.0.15.jar:./api-monitor.jar" (0x00000000)
    +-------------------------------------------------------
    | Internal options:              4
    |   "-Dcommons.daemon.process.id=8919" (0x00000000)
    |   "-Dcommons.daemon.process.parent=8918" (0x00000000)
    |   "-Dcommons.daemon.version=1.0.15-dev" (0x00000000)
    |   "abort" (0x022bef30)
    +-------------------------------------------------------
    Java VM created successfully
    Cannot find daemon loader org/apache/commons/daemon/support/DaemonLoader
    java_init failed
    Service exit with a return value of 1
    
  • Bart van Heukelom
    Bart van Heukelom over 9 years
    Seems like this is new behaviour. Previously, cd'ing to the correct working directory before executing jsvc was sufficient.