ACCUMULO-1472 Rely solely on classpath from the invoking application and prevent extra warnings from being logged.
Create lib/ext so that the classloader doesn't WARN. Since the applications will inherit the classpath from the invoking application, we shouldn't try to pull jars from environment vars (as they will rarely be correct) and add them to the classpath too. Sadly, we must set *something*, otherwise the AccumuloClassLoader will revert back to some default and load things we don't want. Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/748276b5 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/748276b5 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/748276b5 Branch: refs/heads/master Commit: 748276b5b4cd91cd860082a758ec55d013013c9e Parents: 4d8977c Author: Josh Elser <els...@apache.org> Authored: Mon Feb 3 14:32:49 2014 -0500 Committer: Josh Elser <els...@apache.org> Committed: Mon Feb 3 14:32:49 2014 -0500 ---------------------------------------------------------------------- .../accumulo/minicluster/MiniAccumuloCluster.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/748276b5/src/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java ---------------------------------------------------------------------- diff --git a/src/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java b/src/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java index cce422c..cbed375 100644 --- a/src/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java +++ b/src/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java @@ -106,6 +106,7 @@ public class MiniAccumuloCluster { } private File libDir; + private File libExtDir; private File confDir; private File zooKeeperDir; private File accumuloDir; @@ -206,6 +207,7 @@ public class MiniAccumuloCluster { this.config = config; libDir = new File(config.getDir(), "lib"); + libExtDir = new File(libDir, "ext"); confDir = new File(config.getDir(), "conf"); accumuloDir = new File(config.getDir(), "accumulo"); zooKeeperDir = new File(config.getDir(), "zookeeper"); @@ -219,6 +221,10 @@ public class MiniAccumuloCluster { walogDir.mkdirs(); libDir.mkdirs(); + // Avoid the classloader yelling that the general.dynamic.classpaths value is invalid because + // $ACCUMULO_HOME/lib/ext isn't defined. + libExtDir.mkdirs(); + zooKeeperPort = PortUtils.getRandomFreePort(); File siteFile = new File(confDir, "accumulo-site.xml"); @@ -250,12 +256,14 @@ public class MiniAccumuloCluster { // since there is a small amount of memory, check more frequently for majc... setting may not be needed in 1.5 appendProp(fileWriter, Property.TSERV_MAJC_DELAY, "3", siteConfig); - String cp = System.getenv("ACCUMULO_HOME") + "/lib/.*.jar," + "$ZOOKEEPER_HOME/zookeeper[^.].*.jar," + "$HADOOP_HOME/[^.].*.jar," - + "$HADOOP_HOME/lib/[^.].*.jar," + "$HADOOP_PREFIX/share/hadoop/common/.*.jar," + "$HADOOP_PREFIX/share/hadoop/common/lib/.*.jar," - + "$HADOOP_PREFIX/share/hadoop/hdfs/.*.jar," + "$HADOOP_PREFIX/share/hadoop/mapreduce/.*.jar"; - appendProp(fileWriter, Property.GENERAL_CLASSPATHS, cp, siteConfig); - appendProp(fileWriter, Property.GENERAL_DYNAMIC_CLASSPATHS, libDir.getAbsolutePath(), siteConfig); + // ACCUMULO-1472 -- Use the classpath, not what might be installed on the system. + // We have to set *something* here, otherwise the AccumuloClassLoader will default to pulling from + // environment variables (e.g. ACCUMULO_HOME, HADOOP_HOME/PREFIX) which will result in multiple copies + // of artifacts on the classpath as they'll be provided by the invoking application + appendProp(fileWriter, Property.GENERAL_CLASSPATHS, libDir.getAbsolutePath() + "/[^.].*.jar", siteConfig); + appendProp(fileWriter, Property.GENERAL_DYNAMIC_CLASSPATHS, libExtDir.getAbsolutePath() + "/[^.].*.jar", siteConfig); + for (Entry<String,String> entry : siteConfig.entrySet()) fileWriter.append("<property><name>" + entry.getKey() + "</name><value>" + entry.getValue() + "</value></property>\n"); fileWriter.append("</configuration>\n");