[SPARK-30382][SQL] Remove Hive LogUtils usage to prevent ClassNotFoundException
Avoid hive log initialisation as https://github.com/apache/hive/blob/rel/release-2.3.5/common/src/java/org/apache/hadoop/hive/common/LogUtils.java introduces dependency over `org.apache.logging.log4j.core.impl.Log4jContextFactory` which is missing in our spark installer classpath directly. I believe the `LogUtils.initHiveLog4j()` code is here as the HiveServer2 class is copied from Hive. To make `start-thriftserver.sh --help` command success. Currently, start-thriftserver.sh --help throws ``` ... Thrift server options: Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/logging/log4j/spi/LoggerContextFactory at org.apache.hive.service.server.HiveServer2.main(HiveServer2.java:167) at org.apache.spark.sql.hive.thriftserver.HiveThriftServer2$.main(HiveThriftServer2.scala:82) at org.apache.spark.sql.hive.thriftserver.HiveThriftServer2.main(HiveThriftServer2.scala) Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.spi.LoggerContextFactory at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 3 more ``` No Checked Manually Closes #27042 from ajithme/thrifthelp. Authored-by: Ajith <ajith2489@gmail.com> Signed-off-by: Dongjoon Hyun <dhyun@apple.com>
This commit is contained in:
parent
9479887ba1
commit
2be5286828
|
@ -31,8 +31,6 @@ import org.apache.commons.cli.Options;
|
|||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.hive.common.LogUtils;
|
||||
import org.apache.hadoop.hive.common.LogUtils.LogInitializationException;
|
||||
import org.apache.hadoop.hive.conf.HiveConf;
|
||||
import org.apache.hadoop.hive.shims.ShimLoader;
|
||||
import org.apache.hive.common.util.HiveStringUtils;
|
||||
|
@ -153,25 +151,13 @@ public class HiveServer2 extends CompositeService {
|
|||
|
||||
public static void main(String[] args) {
|
||||
HiveConf.setLoadHiveServer2Config(true);
|
||||
try {
|
||||
ServerOptionsProcessor oproc = new ServerOptionsProcessor("hiveserver2");
|
||||
ServerOptionsProcessorResponse oprocResponse = oproc.parse(args);
|
||||
ServerOptionsProcessor oproc = new ServerOptionsProcessor("hiveserver2");
|
||||
ServerOptionsProcessorResponse oprocResponse = oproc.parse(args);
|
||||
|
||||
// NOTE: It is critical to do this here so that log4j is reinitialized
|
||||
// before any of the other core hive classes are loaded
|
||||
String initLog4jMessage = LogUtils.initHiveLog4j();
|
||||
LOG.debug(initLog4jMessage);
|
||||
HiveStringUtils.startupShutdownMessage(HiveServer2.class, args, LOG);
|
||||
HiveStringUtils.startupShutdownMessage(HiveServer2.class, args, LOG);
|
||||
|
||||
// Log debug message from "oproc" after log4j initialize properly
|
||||
LOG.debug(oproc.getDebugMessage().toString());
|
||||
|
||||
// Call the executor which will execute the appropriate command based on the parsed options
|
||||
oprocResponse.getServerOptionsExecutor().execute();
|
||||
} catch (LogInitializationException e) {
|
||||
LOG.error("Error initializing log: " + e.getMessage(), e);
|
||||
System.exit(-1);
|
||||
}
|
||||
// Call the executor which will execute the appropriate command based on the parsed options
|
||||
oprocResponse.getServerOptionsExecutor().execute();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -30,8 +30,6 @@ import org.apache.commons.cli.OptionBuilder;
|
|||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.hadoop.hive.common.JvmPauseMonitor;
|
||||
import org.apache.hadoop.hive.common.LogUtils;
|
||||
import org.apache.hadoop.hive.common.LogUtils.LogInitializationException;
|
||||
import org.apache.hadoop.hive.conf.HiveConf;
|
||||
import org.apache.hive.common.util.HiveStringUtils;
|
||||
import org.apache.hive.service.CompositeService;
|
||||
|
@ -158,25 +156,13 @@ public class HiveServer2 extends CompositeService {
|
|||
|
||||
public static void main(String[] args) {
|
||||
HiveConf.setLoadHiveServer2Config(true);
|
||||
try {
|
||||
ServerOptionsProcessor oproc = new ServerOptionsProcessor("hiveserver2");
|
||||
ServerOptionsProcessorResponse oprocResponse = oproc.parse(args);
|
||||
ServerOptionsProcessor oproc = new ServerOptionsProcessor("hiveserver2");
|
||||
ServerOptionsProcessorResponse oprocResponse = oproc.parse(args);
|
||||
|
||||
// NOTE: It is critical to do this here so that log4j is reinitialized
|
||||
// before any of the other core hive classes are loaded
|
||||
String initLog4jMessage = LogUtils.initHiveLog4j();
|
||||
LOG.debug(initLog4jMessage);
|
||||
HiveStringUtils.startupShutdownMessage(HiveServer2.class, args, LOG);
|
||||
HiveStringUtils.startupShutdownMessage(HiveServer2.class, args, LOG);
|
||||
|
||||
// Log debug message from "oproc" after log4j initialize properly
|
||||
LOG.debug(oproc.getDebugMessage().toString());
|
||||
|
||||
// Call the executor which will execute the appropriate command based on the parsed options
|
||||
oprocResponse.getServerOptionsExecutor().execute();
|
||||
} catch (LogInitializationException e) {
|
||||
LOG.error("Error initializing log: " + e.getMessage(), e);
|
||||
System.exit(-1);
|
||||
}
|
||||
// Call the executor which will execute the appropriate command based on the parsed options
|
||||
oprocResponse.getServerOptionsExecutor().execute();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue