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 Jan Van Besien <ja...@ngdata.com> on 2016/06/22 12:35:04 UTC

JettySolrRunner with webapp

Hi

I was wondering if there is support for running JettySolrRunner
including the solr webapp. We have a use case where we start an
embedded solr (including webui) in a mini-version of our application
where we simply run everything in a single JVM. JettySolrRunner is OK
but lacks the webapp. With the following hack, I can add the webapp:

JettySolrRunner jettySolrRunner = new JettySolrRunner(solrHomeDir,
"/solr", solrPort);
Field serverField = JettySolrRunner.class.getDeclaredField("server");
serverField.setAccessible(true);
Server jettyServer = (Server)serverField.get(jettySolrRunner);

// add web app for UI (which is not available in JettySolrRunner by default)
WebAppContext bb = new WebAppContext();
bb.setServer(jettyServer);
bb.setContextPath("/solr");
bb.setWar("/path/to/lucene-solr/solr/webapp/web");

HandlerCollection handlerCollection = new HandlerCollection();
handlerCollection.addHandler(bb);
handlerCollection.addHandler(jettyServer.getHandler());

jettyServer.setHandler(handlerCollection);

But this feels clumsy and in particular the webapp is afaik not part
of any maven artifact (although previously it was, see
https://issues.apache.org/jira/browse/SOLR-1218) so I have to package
it myself.

Is there a better way to do this?

Thanks
Jan