I am getting this error when i am starting cassandra server

Mahesh Muni picture Mahesh Muni · May 31, 2013 · Viewed 8.9k times · Source

[root@SudeepMangu bin]# ./cassandra -f

xss = -ea -javaagent:/home/sudeep/apache-cassandra-1.2.5-src/lib/jamm-0.2.5.jar -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42 -Xms930M -Xmx930M -Xmn200M -XX:+HeapDumpOnOutOfMemoryError -Xss160k

Exception in thread "main" java.lang.NoClassDefFoundError: *org/apache/cassandra/service/CassandraDaemon* Caused by: java.lang.ClassNotFoundException: org.apache.cassandra.service.CassandraDaemon at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) Could not find the main class: org.apache.cassandra.service.CassandraDaemon. Program will exit.

Answer

Lyuben Todorov picture Lyuben Todorov · Jun 4, 2013

I'm betting you are starting the server under windows.

Exception in thread "main" java.lang.NoClassDefFoundError

You are getting this exception because you haven't set the CASSANDRA_HOME variable, so when you start the server you are trying to find the path to Cassandra but you cant, because that path is constructed using that environment variable.

Simply add the system variable:

setx CASSANDRA_HOME "C:\path\to\cassandra\"    // Windows
export CASSANDRA_HOME=/path/to/cassandra/      // Unix 

Just a heads up doing this in the cmd will require you to open a new prompt.You can also do it using the GUI approach in Windows.