JarHell.checkJarHell(urls, logger::debug); // check jarhell as we add each extended plugin's urls JarHell.checkJarHell(urls, logger::debug); // check jarhell of each extended plugin against this plugin transitiveUrls.put(bundle.plugin.getName(), urls); JarHell.checkJarHell(union, logger::debug); } catch (Exception e) { throw new IllegalStateException("failed to load plugin " + bundle.plugin.getName() + " due to jar hell", e);
JarHell.checkJarHell(logger::debug); } catch (IOException | URISyntaxException e) { throw new BootstrapException(e);
/** Simple driver class, can be used eg. from builds. Returns non-zero on jar-hell */ @SuppressForbidden(reason = "command line tool") public static void main(String args[]) throws Exception { System.out.println("checking for jar hell..."); checkJarHell(); System.out.println("no jar hell found"); }
/** Simple driver class, can be used eg. from builds. Returns non-zero on jar-hell */ @SuppressForbidden(reason = "command line tool") public static void main(String args[]) throws Exception { System.out.println("checking for jar hell..."); checkJarHell(); System.out.println("no jar hell found"); }
/** Simple driver class, can be used eg. from builds. Returns non-zero on jar-hell */ @SuppressForbidden(reason = "command line tool") public static void main(String args[]) throws Exception { System.out.println("checking for jar hell..."); checkJarHell(); System.out.println("no jar hell found"); }
/** Simple driver class, can be used eg. from builds. Returns non-zero on jar-hell */ @SuppressForbidden(reason = "command line tool") public static void main(String args[]) throws Exception { System.out.println("checking for jar hell..."); checkJarHell(System.out::println); System.out.println("no jar hell found"); }
/** * Checks the current classpath for duplicate classes * @param output A {@link String} {@link Consumer} to which debug output will be sent * @throws IllegalStateException if jar hell was found */ public static void checkJarHell(Consumer<String> output) throws IOException, URISyntaxException { ClassLoader loader = JarHell.class.getClassLoader(); output.accept("java.class.path: " + System.getProperty("java.class.path")); output.accept("sun.boot.class.path: " + System.getProperty("sun.boot.class.path")); if (loader instanceof URLClassLoader) { output.accept("classloader urls: " + Arrays.toString(((URLClassLoader)loader).getURLs())); } checkJarHell(parseClassPath(), output); }
/** * Checks the current classpath for duplicate classes * @throws IllegalStateException if jar hell was found */ public static void checkJarHell() throws IOException, URISyntaxException { ClassLoader loader = JarHell.class.getClassLoader(); Logger logger = Loggers.getLogger(JarHell.class); if (logger.isDebugEnabled()) { logger.debug("java.class.path: {}", System.getProperty("java.class.path")); logger.debug("sun.boot.class.path: {}", System.getProperty("sun.boot.class.path")); if (loader instanceof URLClassLoader ) { logger.debug("classloader urls: {}", Arrays.toString(((URLClassLoader)loader).getURLs())); } } checkJarHell(parseClassPath()); }
/** * Checks the current classpath for duplicate classes * @throws IllegalStateException if jar hell was found */ public static void checkJarHell() throws IOException, URISyntaxException { ClassLoader loader = JarHell.class.getClassLoader(); Logger logger = Loggers.getLogger(JarHell.class); if (logger.isDebugEnabled()) { logger.debug("java.class.path: {}", System.getProperty("java.class.path")); logger.debug("sun.boot.class.path: {}", System.getProperty("sun.boot.class.path")); if (loader instanceof URLClassLoader ) { logger.debug("classloader urls: {}", Arrays.toString(((URLClassLoader)loader).getURLs())); } } checkJarHell(parseClassPath()); }
JarHell.checkJarHell(urls, logger::debug); // check jarhell as we add each extended plugin's urls JarHell.checkJarHell(urls, logger::debug); // check jarhell of each extended plugin against this plugin transitiveUrls.put(bundle.plugin.getName(), urls); JarHell.checkJarHell(union, logger::debug); } catch (Exception e) { throw new IllegalStateException("failed to load plugin " + bundle.plugin.getName() + " due to jar hell", e);
JarHell.checkJarHell(urls, logger::debug); // check jarhell as we add each extended plugin's urls JarHell.checkJarHell(urls, logger::debug); // check jarhell of each extended plugin against this plugin transitiveUrls.put(bundle.plugin.getName(), urls); JarHell.checkJarHell(union, logger::debug); } catch (Exception e) { throw new IllegalStateException("failed to load plugin " + bundle.plugin.getName() + " due to jar hell", e);
/** check a candidate plugin for jar hell before installing it */ private void jarHellCheck(Path candidate, boolean isolated) throws IOException { // create list of current jars in classpath final List<URL> jars = new ArrayList<>(); jars.addAll(Arrays.asList(JarHell.parseClassPath())); // read existing bundles. this does some checks on the installation too. List<Bundle> bundles = PluginsService.getPluginBundles(environment.pluginsFile()); // if we aren't isolated, we need to jarhellcheck against any other non-isolated plugins // thats always the first bundle if (isolated == false) { jars.addAll(bundles.get(0).urls); } // add plugin jars to the list Path pluginJars[] = FileSystemUtils.files(candidate, "*.jar"); for (Path jar : pluginJars) { jars.add(jar.toUri().toURL()); } // check combined (current classpath + new jars to-be-added) try { JarHell.checkJarHell(jars.toArray(new URL[jars.size()])); } catch (Exception ex) { throw new RuntimeException(ex); } }
/** * Checks the current classpath for duplicate classes * @throws IllegalStateException if jar hell was found */ public static void checkJarHell() throws Exception { ClassLoader loader = JarHell.class.getClassLoader(); ESLogger logger = Loggers.getLogger(JarHell.class); if (logger.isDebugEnabled()) { logger.debug("java.class.path: {}", System.getProperty("java.class.path")); logger.debug("sun.boot.class.path: {}", System.getProperty("sun.boot.class.path")); if (loader instanceof URLClassLoader ) { logger.debug("classloader urls: {}", Arrays.toString(((URLClassLoader)loader).getURLs())); } } checkJarHell(parseClassPath()); }
JarHell.checkJarHell(union); } catch (Exception e) { throw new IllegalStateException("failed to load plugin " + bundle.plugin +
private List<Tuple<PluginInfo,Plugin>> loadBundles(List<Bundle> bundles) { List<Tuple<PluginInfo, Plugin>> plugins = new ArrayList<>(); for (Bundle bundle : bundles) { // jar-hell check the bundle against the parent classloader // pluginmanager does it, but we do it again, in case lusers mess with jar files manually try { final List<URL> jars = new ArrayList<>(); jars.addAll(Arrays.asList(JarHell.parseClassPath())); jars.addAll(bundle.urls); JarHell.checkJarHell(jars.toArray(new URL[0])); } catch (Exception e) { throw new IllegalStateException("failed to load bundle " + bundle.urls + " due to jar hell", e); } // create a child to load the plugins in this bundle ClassLoader loader = URLClassLoader.newInstance(bundle.urls.toArray(new URL[0]), getClass().getClassLoader()); for (PluginInfo pluginInfo : bundle.plugins) { final Plugin plugin; if (pluginInfo.isJvm()) { // reload lucene SPI with any new services from the plugin reloadLuceneSPI(loader); Class<? extends Plugin> pluginClass = loadPluginClass(pluginInfo.getClassname(), loader); plugin = loadPlugin(pluginClass, settings); } else { plugin = new SitePlugin(pluginInfo.getName(), pluginInfo.getDescription()); } plugins.add(new Tuple<>(pluginInfo, plugin)); } } return Collections.unmodifiableList(plugins); }
JarHell.checkJarHell();
JarHell.checkJarHell(logger::debug); } catch (IOException | URISyntaxException e) { throw new BootstrapException(e);
JarHell.checkJarHell(logger::debug); } catch (IOException | URISyntaxException e) { throw new BootstrapException(e);
JarHell.checkJarHell(); } catch (IOException | URISyntaxException e) { throw new BootstrapException(e);