Class LibExtClassLoaderHelper

java.lang.Object
org.eclipse.jetty.osgi.LibExtClassLoaderHelper

public class LibExtClassLoaderHelper extends Object
LibExtClassLoaderHelper

Helper to create a URL class-loader with the jars inside ${jetty.home}/lib/ext and ${jetty.home}/resources. In an ideal world, every library is an OSGi bundle that does loads nicely. To support standard jars or bundles that cannot be loaded in the current OSGi environment, we support inserting the jars in the usual jetty/lib/ext folders in the proper classpath for the webapps.

The drawback is that those jars will not be available in the OSGi classloader.

Alternatives to placing jars in lib/ext:

  1. Bundle the jars in an osgi bundle. Have the webapp(s) that need these jars depend on that bundle.
  2. Bundle those jars in an osgi bundle-fragment that targets the jetty-bootstrap bundle
  3. Use equinox Buddy-Policy: register a buddy of the jetty bootstrapper bundle. (Note: it will work only on equinox)
  • Constructor Details

    • LibExtClassLoaderHelper

      public LibExtClassLoaderHelper()
  • Method Details

    • createLibExtClassLoader

      public static ClassLoader createLibExtClassLoader(List<File> jarsContainerOrJars, List<URL> otherJarsOrFolder, ClassLoader parentClassLoader) throws MalformedURLException
      Parameters:
      jarsContainerOrJars - the jars via file references
      otherJarsOrFolder - more jars via url references
      parentClassLoader - the parent classloader
      Returns:
      a url classloader with the jars of resources, lib/ext and the jars passed in the other argument. The parent classloader usually is the JettyBootStrapper (an osgi classloader). If there was no extra jars to insert, then just return the parentClassLoader.
      Throws:
      MalformedURLException - if there is a bad jar file reference