Is it possible to override jetty "contextPath" property when starting Solr 5 using command line arguments?
I want something like
bin/solr -p 8983 -s "example/techproducts/solr" -a "-DcontextPath=/s"
So that the base url will be http://localhost:8983/s
To be precise, I want to override exactly contextPath property
Your question is about the context path of solr as jetty webapp.
Instead of
http://localhost:8983/solr/
you want to access solr via
http://localhost:8983/s/
imho this is not possible without changing a configuration file.
Be aware that with zookeeper and solrCloud there is the parameter hostContext in solr.xml and you can use system properties in solr.xml like hostContext.
Without zookeeper but with changing
server\contexts\solr-jetty-context.xml
you will get what you want:
change from
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath"><Property name="hostContext" default="/solr"/></Set>
<Set name="war"><Property name="jetty.base"/>/solr-webapp/webapp</Set>
<Set name="defaultsDescriptor"><Property name="jetty.base"/>/etc/webdefault.xml</Set>
<Set name="extractWAR">false</Set>
</Configure>
to this:
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath"><SystemProperty name="hostContext" default="/solr"/></Set>
<Set name="war"><Property name="jetty.base"/>/solr-webapp/webapp</Set>
<Set name="defaultsDescriptor"><Property name="jetty.base"/>/etc/webdefault.xml</Set>
<Set name="extractWAR">false</Set>
</Configure>
Now you can start with
solr start -a "-DhostContext=/s"