简体   繁体   中英

Solr Setup - Error: Could not find or load main class org.apache.solr.cloud.ZkCLI

I am following the tutorial to set-up Solr ( http://lucene.apache.org/solr/quickstart.html ) using Windows 7, Java version 1.8 and Solr version 4.10.2.

Java is installed at C:\\root\\java and Solr is installed at c:\\root\\solr-4.10.2.

I have added 2 Environment Variables as User variables:

CLASSPATH = C:\ROOT\solr-4.10.2\dist\solr-core-4.10.2.jar
JAVA_HOME = c:\root\java

I then run the following code in my command prompt:

cd c:\root\solr-4.10.2\bin & solr start -e cloud -noprompt

The output is pasted below. The Solr server for collection1 seems to be working fine, although the gettingstarted core was not added. But, why are there errors for ZkCLI and SolrCLI? Am I doing something wrong?

Welcome to the SolrCloud example


Starting up  Solr nodes for your example SolrCloud cluster.
Starting node1 on port 8983 using command:
solr -cloud -p 8983 -d node1

Waiting for  0 seconds, press a key to continue ...
Starting node2 on port 7574 using command:
solr -cloud -p 7574 -d node2 -z localhost:9983

Waiting for  0 seconds, press a key to continue ...

Now let's create a new collection for indexing documents in your 2-node cluster.


Deploying default Solr configuration files to embedded ZooKeeper

Error: Could not find or load main class org.apache.solr.cloud.ZkCLI
Creating new collection gettingstarted with 2 shards and replication factor 2 us
ing Collections API command:

"http://localhost:8983/solr/admin/collections?action=CREATE&name=gettingstarted&
replicationFactor=2&numShards=2&collection.configName=default&maxShardsPerNode=3
&wt=json&indent=2"

For more information about the Collections API, please see: https://cwiki.apache
.org/confluence/display/solr/Collections+API

Error: Could not find or load main class org.apache.solr.util.SolrCLI

SolrCloud example is running, please visit http://localhost:8983/solr"


c:\ROOT\solr-4.10.2\bin>java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

c:\ROOT\solr-4.10.2\bin>

Found this on a different site and it worked for me.

If you run solr without the cloud option, it does a few extra things that are necessary for the cloud option to work.

So, merely run solr.cmd start , then solr.cmd stop -p 8983 to get that preparation.

Then finally run solr.cmd start -e cloud -noprompt .

It should be noted on the tutorial but Solr doesn't seem to be Windows friendly. I think the environment variables are also important so thanks for that info.

Also, make sure you have not downloaded the source archive. The source is about 52mb as of version 6.6.1 (solr-6.6.1-src. ), while the archive you want for the tutorial is about 145mb (solr-6.6.1. ).

Ran into the same issue.

The issue stemmed from the webapp directory already existing in the solr directory. When the demo runs zkcli.sh it checks to see if the webapp directory exists, if it does, it doesn't do anything. If it doesn't exist it actually extracts the solr.war in the webapps directory. By default with the 4.10.2 package that webapp directory exists but is empty which causes stuff throw that fun classpath error.

eg. you extracted solr-4.10.2.tgz to ~/solr-4.10.2

go to ~/solr-4.10.2/example/solr-webapp/webapp, check to see if you have anything in the webapp directory (you shouldn't), delete the webapp directory.

Should fix the issue.

In SolrCloud chapter, the reference guide clearly states:

"Make sure to run Solr from the example directory in non-SolrCloud mode at least once before beginning; this process unpacks the jar files necessary to run SolrCloud. However, do not load documents yet, just start it once and shut it down."

They should update the tutorial with this info.

This worked for me

java -classpath example\\exampledocs\\post.jar -Dauto=yes -Dc=gettingstarted -Ddata=files -Drecursive=yes org.apache.solr.util.SimplePostTool docs/

https://cwiki.apache.org/confluence/display/solr/Post+Tool#PostTool-Windows

I faced the same issue, after search i realized that i missed "ant compile" step.

This worked for me

 1073  tar -zxvf solr-5.3.1-src.tgz
 1074  cd solr-5.3.1
 1076  nano README.txt
 1077  ant compile
 1096  cd solr
 1098  cd bin
 1100  chmod a+x solr
 1108  cd ..
 1111  cd solr
 1112  ant server
 1113  bin/solr start

[vagrant@localhost solr]$ java -version
java version "1.7.0_91"
OpenJDK Runtime Environment (rhel-2.6.2.1.el7_1-x86_64 u91-b00)
OpenJDK 64-Bit Server VM (build 24.91-b01, mixed mode)

[vagrant@localhost solr]$ ant -version
Apache Ant(TM) version 1.9.2 compiled on June 10 2014

[vagrant@localhost solr]$ cat /etc/*release
CentOS Linux release 7.0.1406 (Core)
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CentOS Linux release 7.0.1406 (Core)
CentOS Linux release 7.0.1406 (Core)

The class is bundled in solr-core-4.xyjar, so it must be available in your classpath if you're running an utility script outside of Zookeeper in Solr.

You can find solr-core-4.xyjar under dist/solr-core-4.xyjar . Replace xy with your current version number.

The GitHub distribution of Apache Solr doesn't necessarily correspond to the Solr Reference Guide distribution.

I downloaded the .tgz installation from the Solr Reference Guide and now the program is running in Terminal with bin/solr start and bin/solr start -e cloud

Clarification: with MacOS, I downloaded solr-8.1.0.tgz from the Solr Downloads page

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM