HADOOP-13410. RunJar adds the content of the jar twice to the classpath (Yuanbo Liu via sjlee)
This commit is contained in:
parent
874577a67d
commit
4d3ea92f4f
@ -226,7 +226,7 @@ public void run() {
|
|||||||
|
|
||||||
unJar(file, workDir);
|
unJar(file, workDir);
|
||||||
|
|
||||||
ClassLoader loader = createClassLoader(file, workDir);
|
ClassLoader loader = createClassLoader(workDir);
|
||||||
|
|
||||||
Thread.currentThread().setContextClassLoader(loader);
|
Thread.currentThread().setContextClassLoader(loader);
|
||||||
Class<?> mainClass = Class.forName(mainClassName, true, loader);
|
Class<?> mainClass = Class.forName(mainClassName, true, loader);
|
||||||
@ -250,14 +250,13 @@ public void run() {
|
|||||||
* the user jar as well as the HADOOP_CLASSPATH. Otherwise, it creates a
|
* the user jar as well as the HADOOP_CLASSPATH. Otherwise, it creates a
|
||||||
* classloader that simply adds the user jar to the classpath.
|
* classloader that simply adds the user jar to the classpath.
|
||||||
*/
|
*/
|
||||||
private ClassLoader createClassLoader(File file, final File workDir)
|
private ClassLoader createClassLoader(final File workDir)
|
||||||
throws MalformedURLException {
|
throws MalformedURLException {
|
||||||
ClassLoader loader;
|
ClassLoader loader;
|
||||||
// see if the client classloader is enabled
|
// see if the client classloader is enabled
|
||||||
if (useClientClassLoader()) {
|
if (useClientClassLoader()) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append(workDir).append("/").
|
sb.append(workDir).append("/").
|
||||||
append(File.pathSeparator).append(file).
|
|
||||||
append(File.pathSeparator).append(workDir).append("/classes/").
|
append(File.pathSeparator).append(workDir).append("/classes/").
|
||||||
append(File.pathSeparator).append(workDir).append("/lib/*");
|
append(File.pathSeparator).append(workDir).append("/lib/*");
|
||||||
// HADOOP_CLASSPATH is added to the client classpath
|
// HADOOP_CLASSPATH is added to the client classpath
|
||||||
@ -277,7 +276,6 @@ private ClassLoader createClassLoader(File file, final File workDir)
|
|||||||
} else {
|
} else {
|
||||||
List<URL> classPath = new ArrayList<>();
|
List<URL> classPath = new ArrayList<>();
|
||||||
classPath.add(new File(workDir + "/").toURI().toURL());
|
classPath.add(new File(workDir + "/").toURI().toURL());
|
||||||
classPath.add(file.toURI().toURL());
|
|
||||||
classPath.add(new File(workDir, "classes/").toURI().toURL());
|
classPath.add(new File(workDir, "classes/").toURI().toURL());
|
||||||
File[] libs = new File(workDir, "lib").listFiles();
|
File[] libs = new File(workDir, "lib").listFiles();
|
||||||
if (libs != null) {
|
if (libs != null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user