英文:
Tomcat 9 not starting on linux - Catalina.sh can't use JAVA_OPTS
问题
我们安装了一个新的Tomcat 9,但在启动时遇到了问题。
似乎 **catalina.sh** 无法使用 **JAVA_OPTS**,以下是日志的内容:
/usr/local/tomcat-d-9/bin/catalina.sh 第 505 行:-Djava.security.auth.login.config=: 找不到命令
WEBAPP 存储库(第 507 行)实际上是存在的,所以我感到困惑,而且为什么它会将 URL(第 508 行)解释为目录/存储库呢?
这些只是日志中错误的三个例子,用于说明问题,但对于我的 **setenv.sh** 中的每个 **JAVA_OPTS** 都会发生这种情况。要么是:
1. "没有这样的文件或目录":但实际上文件/目录是存在的
2. "没有这样的文件或目录":但是针对的是一个 URL
3. "找不到命令":但这不是要运行的命令,只是一个参数
我对这个相当新,所以可能错过了一些显而易见的东西。你有什么想法?可能发生了什么?
这是我编辑过的 **setenv.sh** 内容:
```bash
#!/bin/bash
COMMON="/usr/local/etc/BashStartFunctions.bash"
[ ! -e "$COMMON" ] && echo "缺少 $COMMON" && exit 1
source $COMMON
checkUsr
fetchAppEnv
echo "PRG=$1"
JAVA_OPTS="${JAVA_OPTS_EXTRA}
-Dspring.profiles.active=dev \
-Djava.library.path=/usr/lib64:/usr/local/tomcat-apr-connector/lib:/lib64 \
-DWEBAPP-CONF-ROOT=${WEBAPP_CONF_ROOT} \
-Dcas.url=${CAS_URL} \
-Dserver.url=${SERVER_URL} \
-Dcom.vmd.xmltcp.client.XmltcpClient.reuseClientSocket=false \
-Dcom.aubesoft.jdbc.recovery.ChainedJdbcExecutionWithRecoveryHelper.overrideChainProcessorRecoveryFile=${overrideChainProcessorRecoveryFile} \
-Dcom.aubesoft.jdbc.recovery.ChainedJdbcExecutionWithRecoveryHelper.overrideInChainRecoveryFile=${overrideInChainRecoveryFile} \
-Dcom.aubesoft.jdbc.recovery.RecoveryPolicy.overrideDefaultRecoveryFile=${overrideDefaultRecoveryFile} \
-Djavax.net.ssl.trustStore=${TRUSTSTORE} \
-Dapp.id=${APP_ID} \
-Dserver.xml.serverPort=${SERVER_PORT} \
-Djava.awt.headless=true";
if [ "$1" = "start" ];then
JAVA_OPTS="${JAVA_OPTS} \
-Denv=${APP_ENV} \
-Dtomcat.hosts=${TOMCAT_HOSTS} \
-Dstore.url=${store_url} \
-Dlog.dir=${LOG_DIR} \
-Dserver.xml.httpPort=${HTTP_PORT} \
-Dserver.xml.ajp13Port=${AJP13_PORT} \
-Dserver.xml.ajp13.maxThreads=${AJP13_MAX_THREADS} \
-Dserver.xml.httpsPort=${HTTPS_PORT} \
-Dserver.xml.https.maxThreads=${HTTPS_MAX_THREADS} \
-Dserver.xml.https.sslCertFile=${HTTPS_CERT_FILE} \
-Dserver.xml.https.sslCertKeyFile=${HTTPS_CERT_KEY_FILE} \
-Dserver.xml.https.sslKeystoreFile=${HTTPS_KEYSTORE_FILE} \
-Dserver.xml.https.sslKeystorePass=${HTTPS_KEYSTORE_PASS} \
-Dserver.xml.https.sslKeyAlias=${HTTPS_KEYSTORE_KEY_ALIAS} \
-Dserver.xml.jvmRoute=${HOSTNAME}.${AJP13_PORT} \
-Dserver.xml.maxHeaderSize=${MAX_HEADER_SIZE} \
-Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port=${JMX_PORT} \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dscoperta.zone=${SCOPERTA_ZONE} \
-Dscoperta.env=${APP_ENV} \
-Dhttps.protocols=TLSv1 \
-Dsmartd.authentication.signing.secret.file=${SMARTD_AUTHENTICATION_SIGNING_SECRET_FILE} \
-Dspring.profiles.active=${SMARTD_SPRING_PROFILES}
";
if [ ! -z ${CAS_SECURE} ]; then
JAVA_OPTS="${JAVA_OPTS} -Djava.security.auth.login.config=${JAAS_CONFIG} \
-Djava.security.krb5.kdc=${KRB5_KDC} \
-Djava.security.krb5.realm=${KRB5_REALM} \
-Dcas.TGTTimeoutMS=${CAS_TGT_TIMEOUT_MS} \
-Dcas.secure=${CAS_SECURE}";
fi
fi
CATALINA_OUT=/usr/local/tomcat-d-9/logs/catalina_${APP_ID}.out
echo "JAVA_OPTS=$JAVA_OPTS"
英文:
We have a new Tomcat 9 installed but we're having an issue when starting it.
It seems catalina.sh isn't able to work with the JAVA_OPTS, here what the log says :
/usr/local/tomcat-d-9/bin/catalina.sh line 505: -Djava.security.auth.login.config=: command not found
The WEBAPP repo (line 507) actually exists so I'm confused, also why is it interpreting a url (line 508) as a dir/repo ?
These are only 3 examples of the errors in the log to illustrate the issue, but this is happening for every single JAVA_OPTS in my setenv.sh . It's either :
- "no such file or directory" : but the file/directory actually exists
- "no such file or directory" : but it's for a url
- "command not found" : but it's not a command to run, just a parameter
I'm fairly new to this so I might be missing something obvious. Any idea what could be happening here ?
Here's my edited setenv.sh
#!/bin/bash
COMMON="/usr/local/etc/BashStartFunctions.bash"
[ ! -e "$COMMON" ] && echo "Missing $COMMON" && exit 1
source $COMMON
checkUsr
fetchAppEnv
echo "PRG=$1"
JAVA_OPTS="${JAVA_OPTS_EXTRA}
-Dspring.profiles.active=dev \
-Djava.library.path=/usr/lib64:/usr/local/tomcat-apr-connector/lib:/lib64 \
-DWEBAPP-CONF-ROOT=${WEBAPP_CONF_ROOT} \
-Dcas.url=${CAS_URL} \
-Dserver.url=${SERVER_URL} \
-Dcom.vmd.xmltcp.client.XmltcpClient.reuseClientSocket=false \
-Dcom.aubesoft.jdbc.recovery.ChainedJdbcExecutionWithRecoveryHelper.overrideChainProcessorRecoveryFile=${overrideChainProcessorRecoveryFile} \
-Dcom.aubesoft.jdbc.recovery.ChainedJdbcExecutionWithRecoveryHelper.overrideInChainRecoveryFile=${overrideInChainRecoveryFile} \
-Dcom.aubesoft.jdbc.recovery.RecoveryPolicy.overrideDefaultRecoveryFile=${overrideDefaultRecoveryFile} \
-Djavax.net.ssl.trustStore=${TRUSTSTORE} \
-Dapp.id=${APP_ID} \
-Dserver.xml.serverPort=${SERVER_PORT} \
-Djava.awt.headless=true"
if [ "$1" = "start" ];then
JAVA_OPTS="${JAVA_OPTS} \
-Denv=${APP_ENV} \
-Dtomcat.hosts=${TOMCAT_HOSTS} \
-Dstore.url=${store_url} \
-Dlog.dir=${LOG_DIR} \
-Dserver.xml.httpPort=${HTTP_PORT} \
-Dserver.xml.ajp13Port=${AJP13_PORT} \
-Dserver.xml.ajp13.maxThreads=${AJP13_MAX_THREADS} \
-Dserver.xml.httpsPort=${HTTPS_PORT} \
-Dserver.xml.https.maxThreads=${HTTPS_MAX_THREADS} \
-Dserver.xml.https.sslCertFile=${HTTPS_CERT_FILE} \
-Dserver.xml.https.sslCertKeyFile=${HTTPS_CERT_KEY_FILE} \
-Dserver.xml.https.sslKeystoreFile=${HTTPS_KEYSTORE_FILE} \
-Dserver.xml.https.sslKeystorePass=${HTTPS_KEYSTORE_PASS} \
-Dserver.xml.https.sslKeyAlias=${HTTPS_KEYSTORE_KEY_ALIAS} \
-Dserver.xml.jvmRoute=${HOSTNAME}.${AJP13_PORT} \
-Dserver.xml.maxHeaderSize=${MAX_HEADER_SIZE} \
-Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port=${JMX_PORT} \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dscoperta.zone=${SCOPERTA_ZONE} \
-Dscoperta.env=${APP_ENV} \
-Dhttps.protocols=TLSv1 \
-Dsmartd.authentication.signing.secret.file=${SMARTD_AUTHENTICATION_SIGNING_SECRET_FILE} \
-Dspring.profiles.active=${SMARTD_SPRING_PROFILES}
"
if [ ! -z ${CAS_SECURE} ]; then
JAVA_OPTS="${JAVA_OPTS} -Djava.security.auth.login.config=${JAAS_CONFIG} \
-Djava.security.krb5.kdc=${KRB5_KDC} \
-Djava.security.krb5.realm=${KRB5_REALM} \
-Dcas.TGTTimeoutMS=${CAS_TGT_TIMEOUT_MS} \
-Dcas.secure=${CAS_SECURE}"
fi
fi
CATALINA_OUT=/usr/local/tomcat-d-9/logs/catalina_${APP_ID}.out
echo "JAVA_OPTS=$JAVA_OPTS"
EDIT
After the answer of @Olaf Kock, It's now partially working.
The last if in setenv.sh is now the only portion with the error message. I edited the post to show what it currently looks like.
答案1
得分: 1
你正在将你的设置拆分成多行:
-DWEBAPP-CONF-ROOT=/usr/local/webapps-conf/:没有这样的文件或目录
并不是指 /usr/local/webapps-conf/
不存在,而是指 -DWEBAPP-CONF-ROOT=/usr/local/webapps-conf/
不存在(显然)
你可以使用 \
转义换行,例如:
JAVA_OPTS="${JAVA_OPTS} \
-Denv=${APP_ENV} \
-Dtomcat.hosts=${TOMCAT_HOSTS} \
...."
或者
JAVA_OPTS="${JAVA_OPTS} -Denv=${APP_ENV}"
JAVA_OPTS="${JAVA_OPTS} -Dtomcat.hosts=${TOMCAT_HOSTS}"
...."
或者将它们都写在一行里。
另外,考虑使用 CATALINA_OPTS
而不是 JAVA_OPTS
。【1】参考链接
英文:
You're splitting up your settings into multiple lines:
-DWEBAPP-CONF-ROOT=/usr/local/webapps-conf/: No such file or directory
does not refer to /usr/local/webapps-conf/
not existing, but -DWEBAPP-CONF-ROOT=/usr/local/webapps-conf/
not existing (obviously)
You can escape the linebreaks using a \
, e.g.
JAVA_OPTS="${JAVA_OPTS} \
-Denv=${APP_ENV} \
-Dtomcat.hosts=${TOMCAT_HOSTS} \
....
or
JAVA_OPTS="${JAVA_OPTS} -Denv=${APP_ENV}"
JAVA_OPTS="${JAVA_OPTS} -Dtomcat.hosts=${TOMCAT_HOSTS}"
....
or just write them all in a single line.
Also, consider to use CATALINA_OPTS, rather than JAVA_OPTS.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论