Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Could not find or load main class, Cassandra

Tags:

java

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.

like image 788
genclik27 Avatar asked Mar 19 '14 16:03

genclik27


1 Answers

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.
like image 163
Jason C Avatar answered Sep 28 '22 04:09

Jason C