diff --git hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java index 8aa8423..231211f 100644 --- hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java +++ hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java @@ -1186,6 +1186,11 @@ public static void replaceFile(File src, File target) throws IOException { return fileNames; } + public static String createJarWithClassPath(String inputClassPath, Path pwd, + Map callerEnv) throws IOException { + return createJarWithClassPath(inputClassPath, pwd, pwd, callerEnv); + } + /** * Create a jar file at the given path, containing a manifest with a classpath * that references all specified entries. @@ -1210,12 +1215,14 @@ public static void replaceFile(File src, File target) throws IOException { * * @param inputClassPath String input classpath to bundle into the jar manifest * @param pwd Path to working directory to save jar + * @param targetDir path to where the jar execution will have its working dir * @param callerEnv Map caller's environment variables to use * for expansion * @return String absolute path to new jar * @throws IOException if there is an I/O error while writing the jar file */ public static String createJarWithClassPath(String inputClassPath, Path pwd, + Path targetDir, Map callerEnv) throws IOException { // Replace environment variables, case-insensitive on Windows @SuppressWarnings("unchecked") @@ -1257,7 +1264,7 @@ public static String createJarWithClassPath(String inputClassPath, Path pwd, // Append just this entry File fileCpEntry = null; if(!new Path(classPathEntry).isAbsolute()) { - fileCpEntry = new File(workingDir, classPathEntry); + fileCpEntry = new File(targetDir.toString(), classPathEntry); } else { fileCpEntry = new File(classPathEntry); diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/WindowsSecureContainerExecutor.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/WindowsSecureContainerExecutor.java index 2bdcbe2..bf6fd2d 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/WindowsSecureContainerExecutor.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/WindowsSecureContainerExecutor.java @@ -431,14 +431,16 @@ public void startLocalizer(Path nmPrivateContainerTokens, File jvm = new File(new File(System.getProperty("java.home"), "bin"), "java.exe"); command.add(jvm.toString()); + Path cwdPath = new Path(cwdApp.getPath()); // Build a temp classpath jar. See ContainerLaunch.sanitizeEnv(). // Passing CLASSPATH explicitly is *way* too long for command line. String classPath = System.getProperty("java.class.path"); Map env = new HashMap(System.getenv()); - String classPathJar = FileUtil.createJarWithClassPath(classPath, classpathJarPrivateDir, env); + String classPathJar = FileUtil.createJarWithClassPath(classPath, + classpathJarPrivateDir, cwdPath, env); classPathJar = localizeClasspathJar( - new Path(classPathJar), new Path(cwdApp.getPath()), user).toString(); + new Path(classPathJar), cwdPath, user).toString(); command.add("-classpath"); command.add(classPathJar); diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/launcher/ContainerLaunch.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/launcher/ContainerLaunch.java index ce97dbc..12c7064 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/launcher/ContainerLaunch.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/launcher/ContainerLaunch.java @@ -767,9 +767,9 @@ public void sanitizeEnv(Map environment, Path pwd, Map mergedEnv = new HashMap( System.getenv()); mergedEnv.putAll(environment); - + String classPathJar = FileUtil.createJarWithClassPath( - newClassPath.toString(), nmPrivateClasspathJarDir, mergedEnv); + newClassPath.toString(), nmPrivateClasspathJarDir, pwd, mergedEnv); // In a secure cluster the classpath jar must be localized to grant access Path localizedClassPathJar = exec.localizeClasspathJar(new Path(classPathJar), pwd, container.getUser()); environment.put(Environment.CLASSPATH.name(), localizedClassPathJar.toString());