无法将 Tomcat 7 作为 Apache Commons Daemon 启动

无法将 Tomcat 7 作为 Apache Commons Daemon 启动

我一直按照建议进行安装过程这里。我正在尝试将 Tomcat 作为 Unix 守护进程运行,如文档中所述。但是,当我$CATALINA_HOME/bin/jsvc像这样运行时(注意,我在建议中添加了commons-daemon.jarand-debug以及-home ...and ):-server

user@debian:/usr/local/tomcat7$ sudo ./bin/jsvc \
-home $JAVA_HOME -debug -server \
-classpath $CATALINA_HOME/bin/bootstrap.jar:$CATALINA__HOME/bin/tomcat-juli.jar:$CATALINA_HOME/bin/commons-daemon.jar \
-outfile $CATALINA_BASE/logs/catalina.out \
-errfile $CATALINA_BASE/logs/catalina.err \
-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.err

user@debian:/usr/local/tomcat7$ sudo cat logs/catalina.err 
Switching umask back to 022 from 077
Using specific JVM in /usr/local/jvm/jdk1.7.0_75/jre/lib/amd64/server/libjvm.so
Attemtping to load library /usr/local/jvm/jdk1.7.0_75/jre/lib/amd64/server/libjvm.so
JVM library /usr/local/jvm/jdk1.7.0_75/jre/lib/amd64/server/libjvm.so loaded
JVM library entry point found (0x6EE14110)
+-- DUMPING JAVA VM CREATION ARGUMENTS -----------------
| Version:                       0x010004
| Ignore Unrecognized Arguments: False
| Extra options:                 5
|   "-Djava.class.path=/usr/local/tomcat7/bin/bootstrap.jar:/bin/tomcat-juli.jar:/usr/local/tomcat7/bin/commons-daemon.jar" (0x00000000)
|   "-Dcatalina.home=/usr/local/tomcat7" (0x00000000)
|   "-Dcatalina.base=/usr/local/tomcat7" (0x00000000)
|   "-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager" (0x00000000)
|   "-Djava.util.logging.config.file=/usr/local/tomcat7/conf/logging.properties" (0x00000000)
+-------------------------------------------------------
| Internal options:              4
|   "-Dcommons.daemon.process.id=3040" (0x00000000)
|   "-Dcommons.daemon.process.parent=3039" (0x00000000)
|   "-Dcommons.daemon.version=1.0.15-dev" (0x00000000)
|   "abort" (0x00405500)
+-------------------------------------------------------
Java VM created successfully
Class org/apache/commons/daemon/support/DaemonLoader found
Native methods registered
java_init done
Daemon loading...
java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory
    at org.apache.catalina.startup.Bootstrap.<clinit>(Bootstrap.java:59)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at java.lang.Class.newInstance(Class.java:379)
    at org.apache.commons.daemon.support.DaemonLoader.load(DaemonLoader.java:190)
Caused by: java.lang.ClassNotFoundException: org.apache.juli.logging.LogFactory
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 7 more
Cannot load daemon
java_load failed
Service exit with a return value of 3

如果我去寻找使用jar tf $CATALINA_HOME/bin/tomcat-juli.jar它明显存在的类:

user@debian:/usr/local/tomcat7$ jar tf bin/tomcat-juli.jar 
META-INF/MANIFEST.MF
org/apache/juli/AsyncFileHandler$LogEntry.class
org/apache/juli/AsyncFileHandler$LoggerThread.class
org/apache/juli/AsyncFileHandler.class
org/apache/juli/ClassLoaderLogManager$1.class
org/apache/juli/ClassLoaderLogManager$2.class
org/apache/juli/ClassLoaderLogManager$3.class
org/apache/juli/ClassLoaderLogManager$ClassLoaderLogInfo.class
org/apache/juli/ClassLoaderLogManager$Cleaner.class
org/apache/juli/ClassLoaderLogManager$LogNode.class
org/apache/juli/ClassLoaderLogManager$RootLogger.class
org/apache/juli/ClassLoaderLogManager.class
org/apache/juli/DateFormatCache$1.class
org/apache/juli/DateFormatCache$Cache.class
org/apache/juli/DateFormatCache.class
org/apache/juli/FileHandler.class
org/apache/juli/JdkLoggerFormatter.class
org/apache/juli/OneLineFormatter$1.class
org/apache/juli/OneLineFormatter.class
org/apache/juli/VerbatimFormatter.class
org/apache/juli/logging/DirectJDKLog.class
org/apache/juli/logging/Log.class
org/apache/juli/logging/LogConfigurationException.class
org/apache/juli/logging/LogFactory.class
META-INF/NOTICE
META-INF/LICENSE

答案1

jsvc 命令中有一个拼写错误。我写:

-classpath [...]:$CATALINA_HOME/bin/tomcat-juli.jar:[...]

并不是:

-classpath [...]:$CATALINA__HOME/bin/tomcat-juli.jar:[...]

我删除了不必要的下划线,现在它可以工作了。

相关内容