简体   繁体   中英

Error: Could not find or load main class, Cassandra

I am trying to build Casandra project on a Centos server. I downloaded the file from here.

http://apache.bilkent.edu.tr/cassandra/2.0.6/

Here is the README.txt file

This short guide will walk you through getting a basic one node cluster up
and running, and demonstrate some simple reads and writes.

  * tar -zxvf apache-cassandra-$VERSION.tar.gz
  * cd apache-cassandra-$VERSION
  * sudo mkdir -p /var/log/cassandra
  * sudo chown -R `whoami` /var/log/cassandra
  * sudo mkdir -p /var/lib/cassandra
  * sudo chown -R `whoami` /var/lib/cassandra

Note: The sample configuration files in conf/ determine the file-system 
locations Cassandra uses for logging and data storage. You are free to
change these to suit your own environment and adjust the path names
used here accordingly.

Now that we're ready, let's start it up!

  * bin/cassandra -f

As README.txt file suggested I followed these instructions as adapting to my case (I am not root).

tar -zxvf apache-cassandra-2.0.6-src.tar.gz
cd apache-cassandra-2.0.6-src
mkdir -p var/log/cassandra
chown -R `whoami` var/log/cassandra
mkdir -p var/lib/cassandra
chown -R `whoami` var/lib/cassandra

Since I am not root on the server, I can not create my files under /var folder. So, I created new folder var under apache-cassandra-2.0.6-src and put my lib and log files there. Then I followed next instructions from README.txt file.

bin/cassandra -f

However whatever I tried it is no good, I always get this error.

Error: Could not find or load main class org.apache.cassandra.service.CassandraDaemon

How can I fix this problem?

My java version

java -version

java version "1.7.0_51"
OpenJDK Runtime Environment (rhel-2.4.4.1.el6_5-x86_64 u51-b02)
OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)

EDIT: As an extra informaiton, I tried this instructions on my pc, too. Exactly same thing with README.txt file using sudo and it worked.

I see you have downloaded the source package ( apache-cassandra-2.0.6-src.tar.gz ), but the instructions you posted seem to assume it is already built.

You need to build the source package before you can use it; there would be a separate set of instructions for that somewhere.

I suspect you'd rather just run it instead of building it from source. You may have meant to download the binary package apache-cassandra-2.0.6-bin.tar.gz instead (note "bin", not "src" -- this is a traditional naming convention when separating binaries from source in downloadable archives). With that package you can just run it right out of the box. For the source package you'd need to follow the build instructions to compile cassandra first.

I also suspect that you downloaded the binary package on the PC side, which is why it worked there.

If you do need to build from source:

  1. Install ant and ant-optional if you do not already have it.
  2. Extract the source archive somewhere, then in the base directory (where build.xml is):

     ant release
  3. Make a cup of coffee (the rat task at the end takes forever).
  4. Binary archives will be created in build , and a built distribution can be found in build/dist .

do a export CASSANDRA_HOME=location of cassandra

should work in 2.0.6 i verified just then without setting that variable and after setting those variables.

$ export CASSANDRA_HOME=/usr/local/cassandra/dsc-cassandra-2.0.6
$ /usr/local/cassandra/dsc-cassandra-2.0.6/bin/cassandra


or
$ cd /usr/local/cassandra/dsc-cassandra-2.0.6
$ export CASSANDRA_HOME=
$ bin/cassandra

in fact you can also set CASSANDRA_HOME= in cassandra-2.0.6 directory. set it to empty value if you are executing the export command from the cassandra directory.

Path for CASSANDRA_HOME was incorrect for me. After i set the correct path it ran perfectly.

In the cassandra.yaml configuration file, change the

commitlog_directory
data_file_directories
saved_caches_directory

properties to the path you have specified as they are no longer /var/lib...

You will need to set them to point to wherever the directories actually are.

I faced exact problem, where I wanted to install cassandra in userspace without any sudo privileges. I did the following

In cassandra.yaml I changed the following config to local path

commitlog_directory
data_file_directories
saved_caches_directory
log4j.appender.R.File

Installed the "bin" tar files for the particular OS env and not the "src" file.

Export CASSANDRA_HOME=/userspace/cassandra-2.x

Now it works fine for me.

I faced same issue when I used Jdk 1.8_281 version. The problem was resolved when I downgraded to jdk 1.8_241 version.

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