I've written a class called MultiThread which implements Daemon. However when I try to run it with jsvc, it fails although the class is clearly present in my classpath. What am I not seeing? The call and debug are below:
$ sudo ~/bin/jsvc -jvm server -debug -cp ~/.m2/repository/commons-daemon/commons-daemon/1.0.15/commons-daemon-1.0.15.jar:./target/MultiThread-1.0-SNAPSHOT.jar com.mindwrap.sample.thread.MultiThread once Password: +-- 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=/Users/thad/.m2/repository/commons-daemon/commons-daemon/1.0.15/commons-daemon-1.0.15.jar:./target/MultiThread-1.0-SNAPSHOT.jar" | Class Invoked: "com.mindwrap.sample.thread.MultiThread" | Class Arguments: 1 | "once" +------------------------------------------------------- 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" +------------------------------------------------------- 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 [email protected]:~/jdevel/MultiThreadTest 621 $ 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 (0x09E34762) +-- DUMPING JAVA VM CREATION ARGUMENTS ----------------- | Version: 0x010004 | Ignore Unrecognized Arguments: False | Extra options: 1 | "-Djava.class.path=/Users/thad/.m2/repository/commons-daemon/commons-daemon/1.0.15/commons-daemon-1.0.15.jar:./target/MultiThread-1.0-SNAPSHOT.jar" (0x00000000) +------------------------------------------------------- | Internal options: 4 | "-Dcommons.daemon.process.id=17848" (0x00000000) | "-Dcommons.daemon.process.parent=17847" (0x00000000) | "-Dcommons.daemon.version=1.0.15-dev" (0x00000000) | "abort" (0x096a6f50) +------------------------------------------------------- Java VM created successfully Class org/apache/commons/daemon/support/DaemonLoader found Native methods registered java_init done Daemon loading... java.lang.ClassNotFoundException: com.mindwrap.sample.thread.MultiThread at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) at org.apache.commons.daemon.support.DaemonLoader.load(DaemonLoader.java:151) Cannot load daemon java_load failed Service exit with a return value of 3 As you can see, the class is in the jar: $ jar tvf target/MultiThread-1.0-SNAPSHOT.jar 0 Tue Nov 19 12:08:06 EST 2013 META-INF/ 168 Tue Nov 19 12:08:04 EST 2013 META-INF/MANIFEST.MF 0 Tue Nov 19 12:08:04 EST 2013 com/ 0 Tue Nov 19 12:08:04 EST 2013 com/mindwrap/ 0 Tue Nov 19 12:08:04 EST 2013 com/mindwrap/sample/ 0 Tue Nov 19 12:08:04 EST 2013 com/mindwrap/sample/thread/ 2255 Tue Nov 19 12:08:04 EST 2013 com/mindwrap/sample/thread/MultiThread$ShutdownHook.class 4659 Tue Nov 19 12:08:04 EST 2013 com/mindwrap/sample/thread/MultiThread.class 253 Tue Nov 19 12:08:04 EST 2013 com/mindwrap/sample/thread/ShutdownHookTest$1.class 951 Tue Nov 19 12:08:04 EST 2013 com/mindwrap/sample/thread/ShutdownHookTest$JVMShutdownHook.class 1191 Tue Nov 19 12:08:04 EST 2013 com/mindwrap/sample/thread/ShutdownHookTest.class 2053 Tue Nov 19 12:08:04 EST 2013 com/mindwrap/sample/thread/SubThread.class 282 Tue Nov 19 12:08:04 EST 2013 com/mindwrap/sample/thread/SubThreadMBean.class 0 Tue Nov 19 12:08:06 EST 2013 META-INF/maven/ 0 Tue Nov 19 12:08:06 EST 2013 META-INF/maven/com.mindwrap.sample.thread/ 0 Tue Nov 19 12:08:06 EST 2013 META-INF/maven/com.mindwrap.sample.thread/MultiThread/ 1679 Tue Nov 19 12:07:52 EST 2013 META-INF/maven/com.mindwrap.sample.thread/MultiThread/pom.xml 129 Tue Nov 19 12:08:06 EST 2013 META-INF/maven/com.mindwrap.sample.thread/MultiThread/pom.properties -- "Hell hath no limits, nor is circumscrib'd In one self-place; but where we are is hell, And where hell is, there must we ever be" --Christopher Marlowe, *Doctor Faustus* (v, 121-24)
