Repository: zeppelin Updated Branches: refs/heads/master 3db819abf -> c88010fd0
ZEPPELIN-1326: make profile to select dependency of hadoop-common for JDBC interpreter ### What is this PR for? Extension of https://github.com/apache/zeppelin/pull/1353 java.lang.ClassNotFoundException: org.apache.hadoop.security.UserGroupInformation$AuthenticationMethod error on using jdbc interpreter after #1205 ``` java.lang.ClassNotFoundException: org.apache.hadoop.security.UserGroupInformation$AuthenticationMethod 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) at org.apache.zeppelin.jdbc.security.JDBCSecurityImpl.getAuthtype(JDBCSecurityImpl.java:71) at org.apache.zeppelin.jdbc.JDBCInterpreter.getConnection(JDBCInterpreter.java:217) at org.apache.zeppelin.jdbc.JDBCInterpreter.getStatement(JDBCInterpreter.java:275) at org.apache.zeppelin.jdbc.JDBCInterpreter.executeSql(JDBCInterpreter.java:346) at org.apache.zeppelin.jdbc.JDBCInterpreter.interpret(JDBCInterpreter.java:452) at org.apache.zeppelin.interpreter.LazyOpenInterpreter.interpret(LazyOpenInterpreter.java:94) at org.apache.zeppelin.interpreter.remote.RemoteInterpreterServer$InterpretJob.jobRun(RemoteInterpreterServer.java:383) at org.apache.zeppelin.scheduler.Job.run(Job.java:176) at org.apache.zeppelin.scheduler.FIFOScheduler$1.run(FIFOScheduler.java:139) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) ``` Workaround is adding "org.apache.hadoop:hadoop-common:2.7.2" in the Dependencies section of interpreter setting on GUI. But jdbc interpreter supposed to work without asking user hadoop-common dependency. ### What type of PR is it? [Bug Fix] ### What is the Jira issue? * [ZEPPELIN-1326](https://issues.apache.org/jira/browse/ZEPPELIN-1326) ### How should this be tested? On running this (JDBC) interpreter, the above stack trace should not come. ### Screenshots (if appropriate) ### Questions: * Does the licenses files need update? n/a * Is there breaking changes for older versions? n/a * Does this needs documentation? n/a Author: Prabhjyot Singh <prabhjyotsi...@gmail.com> Closes #1380 from prabhjyotsingh/ZEPPELIN-1326 and squashes the following commits: 903796d [Prabhjyot Singh] revert move profile hadoop-* to root level pom 033da7b [Prabhjyot Singh] check if auth type is present in key f64dbf0 [Prabhjyot Singh] make <scope>provided</scope> 0e0016a [Prabhjyot Singh] move profile hadoop-* to root level pom f061da0 [Prabhjyot Singh] ZEPPELIN-1326: make profile to select dependency for hadoop-common Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/c88010fd Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/c88010fd Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/c88010fd Branch: refs/heads/master Commit: c88010fd0a744d026b75d02bc62bc6dc690f0f9a Parents: 3db819a Author: Prabhjyot Singh <prabhjyotsi...@gmail.com> Authored: Mon Aug 29 16:20:40 2016 +0530 Committer: Prabhjyot Singh <prabhjyotsi...@gmail.com> Committed: Thu Sep 8 14:30:59 2016 +0530 ---------------------------------------------------------------------- .../apache/zeppelin/jdbc/JDBCInterpreter.java | 83 ++++++++++---------- .../jdbc/security/JDBCSecurityImpl.java | 1 - 2 files changed, 43 insertions(+), 41 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zeppelin/blob/c88010fd/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java ---------------------------------------------------------------------- diff --git a/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java b/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java index 68a1ce4..bc473ea 100644 --- a/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java +++ b/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java @@ -27,7 +27,7 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.*; -import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang.StringUtils; import org.apache.hadoop.security.UserGroupInformation; import org.apache.zeppelin.interpreter.Interpreter; import org.apache.zeppelin.interpreter.InterpreterContext; @@ -168,7 +168,7 @@ public class JDBCInterpreter extends Interpreter { logger.debug("propertiesMap: {}", propertiesMap); - if (!StringUtils.isAnyEmpty(property.getProperty("zeppelin.jdbc.auth.type"))) { + if (!StringUtils.isEmpty(property.getProperty("zeppelin.jdbc.auth.type"))) { JDBCSecurityImpl.createSecureConfiguration(property); } for (String propertyKey : propertiesMap.keySet()) { @@ -215,49 +215,52 @@ public class JDBCInterpreter extends Interpreter { Class.forName(properties.getProperty(DRIVER_KEY)); final String url = properties.getProperty(URL_KEY); - UserGroupInformation.AuthenticationMethod authType = JDBCSecurityImpl.getAuthtype(property); - switch (authType) { - case KERBEROS: - if (user == null) { - connection = DriverManager.getConnection(url, properties); - } else { - if ("hive".equalsIgnoreCase(propertyKey)) { - connection = DriverManager.getConnection(url + ";hive.server2.proxy.user=" + user, - properties); + if (StringUtils.isEmpty(property.getProperty("zeppelin.jdbc.auth.type"))) { + connection = DriverManager.getConnection(url, properties); + } else { + UserGroupInformation.AuthenticationMethod authType = JDBCSecurityImpl.getAuthtype(property); + switch (authType) { + case KERBEROS: + if (user == null) { + connection = DriverManager.getConnection(url, properties); } else { - UserGroupInformation ugi = null; - try { - ugi = UserGroupInformation.createProxyUser(user, - UserGroupInformation.getCurrentUser()); - } catch (Exception e) { - logger.error("Error in createProxyUser", e); - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(e.getMessage()).append("\n"); - stringBuilder.append(e.getCause()); - throw new InterpreterException(stringBuilder.toString()); - } - try { - connection = ugi.doAs(new PrivilegedExceptionAction<Connection>() { - @Override - public Connection run() throws Exception { - return DriverManager.getConnection(url, properties); - } - }); - } catch (Exception e) { - logger.error("Error in doAs", e); - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(e.getMessage()).append("\n"); - stringBuilder.append(e.getCause()); - throw new InterpreterException(stringBuilder.toString()); + if ("hive".equalsIgnoreCase(propertyKey)) { + connection = DriverManager.getConnection(url + ";hive.server2.proxy.user=" + user, + properties); + } else { + UserGroupInformation ugi = null; + try { + ugi = UserGroupInformation.createProxyUser(user, + UserGroupInformation.getCurrentUser()); + } catch (Exception e) { + logger.error("Error in createProxyUser", e); + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append(e.getMessage()).append("\n"); + stringBuilder.append(e.getCause()); + throw new InterpreterException(stringBuilder.toString()); + } + try { + connection = ugi.doAs(new PrivilegedExceptionAction<Connection>() { + @Override + public Connection run() throws Exception { + return DriverManager.getConnection(url, properties); + } + }); + } catch (Exception e) { + logger.error("Error in doAs", e); + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append(e.getMessage()).append("\n"); + stringBuilder.append(e.getCause()); + throw new InterpreterException(stringBuilder.toString()); + } } } - } - break; + break; - default: - connection = DriverManager.getConnection(url, properties); + default: + connection = DriverManager.getConnection(url, properties); + } } - } propertyKeySqlCompleterMap.put(propertyKey, createSqlCompleter(connection)); return connection; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/c88010fd/jdbc/src/main/java/org/apache/zeppelin/jdbc/security/JDBCSecurityImpl.java ---------------------------------------------------------------------- diff --git a/jdbc/src/main/java/org/apache/zeppelin/jdbc/security/JDBCSecurityImpl.java b/jdbc/src/main/java/org/apache/zeppelin/jdbc/security/JDBCSecurityImpl.java index 8cc2735..32a7990 100644 --- a/jdbc/src/main/java/org/apache/zeppelin/jdbc/security/JDBCSecurityImpl.java +++ b/jdbc/src/main/java/org/apache/zeppelin/jdbc/security/JDBCSecurityImpl.java @@ -18,7 +18,6 @@ package org.apache.zeppelin.jdbc.security; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.security.UserGroupInformation; -import org.apache.zeppelin.jdbc.SqlCompleter; import org.slf4j.Logger; import org.slf4j.LoggerFactory;