You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Benson Margulies <bi...@gmail.com> on 2009/09/23 00:50:29 UTC

A little discovery about the solr classpath and jetty

On (at least) two occasions, I've opened JIRAs due to my getting tangled up
with eclipse, jetty, and solr/lib.

Well, it occurs to me that a recent idea might be of general use to others
in this regard.

This fragment is offered for illustration. The idea here is that you can
configure the jetty WebAppClassLoader to add an additional lib directory
and/or directory of open class files, such as a directory that Eclipse is
writing into. This is 'as good as' solr/lib, and allows seamless Eclipse
development.

            File sourceDirFile = new
File(webapp.getWebappSourceDirectory());
            WebAppContext wac = new
WebAppContext(sourceDirFile.getCanonicalPath(), webapp.getContextPath());
            WebAppClassLoader loader = new WebAppClassLoader(wac);
            if (webapp.getLibDirectory() != null) {
                Resource r = Resource.newResource(webapp.getLibDirectory());
                loader.addJars(r);
            }
            if (webapp.getClasspathEntries() != null) {
                for (String dir : webapp.getClasspathEntries()) {
                    loader.addClassPath(dir);
                }
            }
            wac.setClassLoader(loader);
            server.addHandler(wac);