I'm currently running Solr out of a Jetty container that it ships with. It runs correctly when run from the command line via:
java -jar start.jar
when I'm in the same directory as start.jar. Unfortunately I need to be able to launch jetty from any directory, not just the one that contains start.jar. I've tried many options, such as:
java -Dsolr.solr.home=~/solr/ -Djetty.home=~/solr/ -Djetty.logs=~/solr/logs/ -cp ~/solr/start.jar:~/solr/lib/jetty-util-6.1.26-patched-JETTY-1340.jar:~/solr/lib/jetty-6.1.26-patched-JETTY-1340.jar:~/solr/lib/servlet-api-2.5-20081211.jar -jar ~/solr/start.jar ~/solr/etc/jetty.xml
Every time I get this backtrace:
java.lang.ClassNotFoundException: org.mortbay.xml.XmlConfiguration
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at org.mortbay.start.Main.invokeMain(Main.java:179)
at org.mortbay.start.Main.start(Main.java:534)
at org.mortbay.start.Main.start(Main.java:441)
at org.mortbay.start.Main.main(Main.java:119)
Simply changing to the correct directory before calling java.... fixed the problem for me.
Note that when you run
java ... -cp ~/solr/start.jar:... -jar ~/solr/start.jar ~/solr/etc/jetty.xml
the -cp
option is ignored since you use the -jar
option.
From man java
:
-jar
When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored.
You have two options:
-jar
option, but then you need to provide the classpath in the jar manifest file (note that these classpath entries can't be relative to the current path, only relative to the jar-file you're executing)-jar
option and provide the main class explicitly.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With