Skip to content

Commit

Permalink
RANGER-3092: KMS fails to start with NullPointerException in catalina…
Browse files Browse the repository at this point in the history
….out logs

Signed-off-by: pradeep <pradeep@apache.org>
  • Loading branch information
maheshbandal15 authored and pradeepagrawal8184 committed Dec 4, 2020
1 parent 7b82a84 commit cbd4cdb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,15 @@ public EmbeddedServer(String[] args) {
configFile = args[0];
}

// load log configuration file dynamically if log4j.properties changed
String logPropFile = StringUtils.splitByWholeSeparator(System.getProperty("log4j.configuration"), ":")[1];
PropertyConfigurator.configureAndWatch(logPropFile, 10000L);
try {
// load log configuration file dynamically if log4j.properties changed
if (StringUtils.isNotBlank(System.getProperty("log4j.configuration"))) {
String logPropFile = StringUtils.splitByWholeSeparator(System.getProperty("log4j.configuration"), ":")[1];
PropertyConfigurator.configureAndWatch(logPropFile, 10000L);
}
} catch (Exception ignored) {
LOG.warning("Failed to get log4j.configuration Reason: " + ignored.toString());
}

EmbeddedServerUtil.loadRangerConfigProperties(configFile);
}
Expand Down
3 changes: 2 additions & 1 deletion kms/scripts/ranger-kms
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ TOMCAT_LOG_DIR=${RANGER_KMS_LOG_DIR}

TOMCAT_LOG_FILE=${TOMCAT_LOG_DIR}/catalina.out
TOMCAT_STOP_LOG_FILE=${TOMCAT_LOG_DIR}/stop_catalina.out
KMS_LOG_PROPERTIES_FILE=${RANGER_KMS_EWS_CONF_DIR}/kms-log4j.properties

if [ ! -d ${TOMCAT_LOG_DIR} ]
then
Expand All @@ -106,7 +107,7 @@ fi

KMS_CONF_DIR=${RANGER_KMS_EWS_DIR}/webapp/WEB-INF/classes/conf
SERVER_NAME=rangerkms
JAVA_OPTS="${JAVA_OPTS} ${DB_SSL_PARAM} -Duser=${USER} -Dhostname=${HOSTNAME} -Dservername=${SERVER_NAME} -Dcatalina.base=${RANGER_KMS_EWS_DIR} -Dkms.config.dir=${KMS_CONF_DIR} -Dkms.log.dir=${TOMCAT_LOG_DIR} -cp ${RANGER_KMS_EWS_CONF_DIR}:${RANGER_KMS_EWS_LIB_DIR}/*:${RANGER_KMS_EWS_DIR}/webapp/lib/*:${JAVA_HOME}/lib/*:${RANGER_HADOOP_CONF_DIR}/*:$CLASSPATH "
JAVA_OPTS="${JAVA_OPTS} ${DB_SSL_PARAM} -Duser=${USER} -Dhostname=${HOSTNAME} -Dservername=${SERVER_NAME} -Dcatalina.base=${RANGER_KMS_EWS_DIR} -Dkms.config.dir=${KMS_CONF_DIR} -Dlog4j.configuration=file:${KMS_LOG_PROPERTIES_FILE} -Dkms.log.dir=${TOMCAT_LOG_DIR} -cp ${RANGER_KMS_EWS_CONF_DIR}:${RANGER_KMS_EWS_LIB_DIR}/*:${RANGER_KMS_EWS_DIR}/webapp/lib/*:${JAVA_HOME}/lib/*:${RANGER_HADOOP_CONF_DIR}/*:$CLASSPATH "
createRangerKMSPid () {
SLEEP_TIME_AFTER_START=5
nohup java -D${PROC_NAME} ${JAVA_OPTS} ${START_CLASS_NAME} ${KMS_CONFIG_FILENAME} > ${TOMCAT_LOG_FILE} 2>&1 &
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,15 @@ public class TagSynchronizer {

public static void main(String[] args) {

// load log configuration file dynamically if log4j.properties changed
String logPropFile = StringUtils.splitByWholeSeparator(System.getProperty("log4j.configuration"), ":")[1];
PropertyConfigurator.configureAndWatch(logPropFile, 10000L);
try {
// load log configuration file dynamically if log4j.properties changed
if (StringUtils.isNotBlank(System.getProperty("log4j.configuration"))) {
String logPropFile = StringUtils.splitByWholeSeparator(System.getProperty("log4j.configuration"), ":")[1];
PropertyConfigurator.configureAndWatch(logPropFile, 10000L);
}
} catch (Exception ignored) {
LOG.warn("Failed to get log4j.configuration Reason: " + ignored.toString());
}

TagSynchronizer tagSynchronizer = new TagSynchronizer();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,15 @@ public class UnixAuthenticationService {

public static void main(String[] args) {

// load log configuration file dynamically if log4j.properties changed
String logPropFile = StringUtils.splitByWholeSeparator(System.getProperty("log4j.configuration"), ":")[1];
PropertyConfigurator.configureAndWatch(logPropFile, 10000L);
try {
// load log configuration file dynamically if log4j.properties changed
if (StringUtils.isNotBlank(System.getProperty("log4j.configuration"))) {
String logPropFile = StringUtils.splitByWholeSeparator(System.getProperty("log4j.configuration"), ":")[1];
PropertyConfigurator.configureAndWatch(logPropFile, 10000L);
}
} catch (Exception ignored) {
LOG.warn("Failed to get log4j.configuration Reason: " + ignored.toString());
}

if (args.length > 0) {
for (String s : args) {
Expand Down

0 comments on commit cbd4cdb

Please sign in to comment.