Index: hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/tool/TempletonControllerJob.java =================================================================== --- hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/tool/TempletonControllerJob.java (revision 1540846) +++ hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/tool/TempletonControllerJob.java (working copy) @@ -83,7 +83,7 @@ private static final String TMP_DIR_PROP = "hadoop.tmp.dir"; /** - * Copy the file from local file system to tmp dir + * Copy the file from local file system to home dir of the user WebHCat is running as */ private static URI copyLog4JtoFileSystem(final String localFile) throws IOException, InterruptedException { @@ -92,16 +92,25 @@ @Override public URI run() throws IOException { AppConfig appConfig = Main.getAppConfigInstance(); - String fsTmpDir = appConfig.get(TMP_DIR_PROP); - if(fsTmpDir == null || fsTmpDir.length() <= 0) { - LOG.warn("Could not find 'hadoop.tmp.dir'; " + affectedMsg); - return null; - } + String fsTmpDir = HiveConf.ConfVars.SCRATCHDIR.toString(); FileSystem fs = FileSystem.get(appConfig); Path dirPath = new Path(fsTmpDir); - if(!fs.exists(dirPath)) { - LOG.warn(dirPath + " does not exist; " + affectedMsg); - return null; + + // 1. Could not find the SCRATCHDIR directory in HDFS + // 2. Could not create the SCRATCHDIR directory + if (!fs.exists(dirPath) && + !fs.mkdirs(dirPath, new FsPermission((short)0775))) { + // If we cannot create SCRATCHDIR, try /users + fsTmpDir = Path.SEPARATOR + "users"; + LOG.warn("Could not find " + HiveConf.ConfVars.SCRATCHDIR.toString() + + "; will try " + fsTmpDir); + dirPath = new Path(fsTmpDir); + // If we cannot create /users as well, throw an + // exception since we cannot copy Log4J to HDFS + if (!fs.exists(dirPath) && !fs.mkdirs(dirPath)) { + throw new RuntimeException( + "Please provide access to /users to copy Log4J"); + } } Path dst = fs.makeQualified(new Path(fsTmpDir, CONTAINER_LOG4J_PROPS)); fs.copyFromLocalFile(new Path(localFile), dst);