Jelajahi Sumber

HUE-208. Beeswax should load auxiliary libs specified via hive.aux.jars.path to classpath.

Signed-off-by: Shrijeet <shrijeet@rocketfuel.com>
Shrijeet 15 tahun lalu
induk
melakukan
ef7d368f68

+ 12 - 0
apps/beeswax/java/src/com/cloudera/beeswax/BeeswaxServiceImpl.java

@@ -42,6 +42,7 @@ import java.util.Vector;
 import javax.net.ssl.HttpsURLConnection;
 import javax.net.ssl.SSLContext;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.metastore.api.FieldSchema;
@@ -261,6 +262,17 @@ public class BeeswaxServiceImpl implements BeeswaxService.Iface {
       }
 
       driver = new Driver(hiveConf);
+      ClassLoader loader = hiveConf.getClassLoader();
+      String auxJars = HiveConf.getVar(hiveConf, HiveConf.ConfVars.HIVEAUXJARS);
+      if (StringUtils.isNotBlank(auxJars)) {
+        try {
+          loader = Utilities.addToClassPath(loader, StringUtils.split(auxJars, ","));
+        } catch (Exception e) {
+          LOG.error("Failed to add jars to class loader: " + auxJars, e);
+        }
+      }
+      hiveConf.setClassLoader(loader);
+      Thread.currentThread().setContextClassLoader(loader);
       SessionState.start(hiveConf); // this is thread-local
       this.sessionState = SessionState.get();