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);

Reply via email to