我在commons-daemon-x.jar中有classpathJsvc成功启动了Java VM。但是jsvc报告说,即使它位于classpath中,也找不到守护程序加载程序类。

有谁知道如何解决这个问题?我正在运行Mac OS X 10.8.3。谢谢。

这是jsvc调试输出的摘录:

...
+-- 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
...

如果有帮助,请参见完整的调试输出:
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

最佳答案

您可能现在已经找到了解决方案,但是以防万一将来有人迷失了方向,我在我的遗漏中是当前目录默认为'/',因此如果要使用相对路径,则必须指定它。

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

注意:我的操作系统是ubuntu 12.10

09-15 22:46