Index: ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java (revision 1465582) +++ ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java (working copy) @@ -40,6 +40,7 @@ import java.io.PrintStream; import java.io.Serializable; import java.io.UnsupportedEncodingException; +import java.lang.reflect.Method; import java.net.URI; import java.net.URL; import java.net.URLClassLoader; @@ -1546,28 +1547,19 @@ */ public static ClassLoader addToClassPath(ClassLoader cloader, String[] newPaths) throws Exception { URLClassLoader loader = (URLClassLoader) cloader; - List curPath = Arrays.asList(loader.getURLs()); - ArrayList newPath = new ArrayList(); + Class classLoaderClass = URLClassLoader.class; - // get a list with the current classpath components - for (URL onePath : curPath) { - newPath.add(onePath); - } - curPath = newPath; - - for (String onestr : newPaths) { - // special processing for hadoop-17. file:// needs to be removed - if (StringUtils.indexOf(onestr, "file://") == 0) { - onestr = StringUtils.substring(onestr, 7); + try { + Method method = classLoaderClass.getDeclaredMethod("addURL", new Class[] {URL.class}); + method.setAccessible(true); + for (int i = 0; i < newPaths.length; i++) { + method.invoke(loader, new Object[] {(new File(newPaths[i])).toURL()}); } - - URL oneurl = (new File(onestr)).toURL(); - if (!curPath.contains(oneurl)) { - curPath.add(oneurl); - } + } catch (Throwable t) { + throw new RuntimeException(t); } - return new URLClassLoader(curPath.toArray(new URL[0]), loader); + return loader; } /**