0
votes

I'm fully aware that this question has already been asked in a way in this thread:

Cassandra:UnsupportedClassVersionError

However, the answer/s given there, which I accept, don't solve my problem as I do have a current version of Java as detailed below:

D:\Development\Cassandra\apache-cassandra-2.0.6>java -version

java version "1.7.0_45" Java(TM) SE Runtime Environment (build 1.7.0_45-b18) Java HotSpot(TM) Client VM (build 24.45-b08, mixed mode, sharing)

Knowing this, I still receive the error when starting Cassandra:

D:\Development\Cassandra\apache-cassandra-2.0.6>bin\cassandra -f Starting Cassandra Server Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/cassandra/service/CassandraDaemon : Unsupported major.minor version 51.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) at java.lang.ClassLoader.defineClass(ClassLoader.java:615) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) at java.net.URLClassLoader.access$000(URLClassLoader.java:58) at java.net.URLClassLoader$1.run(URLClassLoader.java:197) 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.

I'm running on a Windows XP machine using the command prompt (not Cygwin) to start Cassandra and I'm able to start older versions of Cassandra without any issue (apache-cassandra-1.1.4). Am I doing something incorrect with the later version of Cassandra or have I missed something somewhere in my configuration that is blindingly obvious?

2
How do you start cassandra? The stacktrace is definitively not produced by a Java 7 vm. - Dirk Lachowski
I start it using bin\cassandra -f as I do when starting the older version. - Azkuma
It is possible that JAVA_HOME environment variable points to JDK6 while the PATH points to JDK7. This would explain the proper java version from the command line and improper from the cassandra startup script. What is the output of "%JAVA_HOME%\bin\java" -version (on Windows)? - Oleg Estekhin
Or there is a JAVA_HOME entry in one of your cassandra.in.sh. - Dirk Lachowski
No, I have made absolutely sure that both my JAVA_HOME and PATH contain the correct settings e.g. JAVA_HOME = D:\Development\Java\jdk1.7.0_45\ and PATH = D:\Development\Java\jdk1.7.0_45\bin; - Azkuma

2 Answers

0
votes

The only plausible explanation for that exception is that a Java 6 (or earlier) JVM is being use to run code that was compiled for the Java 7 target platform.

This contradicts what you believe to be happening. Nevertheless, it is the only plausible explanation.

I suggest that you make a copy of the cassandra wrapper script (in the same directory), and hack it to:

  1. add set -x at the start to see what commands are actually being run by the script.

  2. add echo $PATH, echo $JAVA_HOME and so on to see what the key environment variables are in the script's environment.

  3. add a line to run java -version using the exact same command path that is being use to run the JVM for real.

This should reveal which of your beliefs / assumptions about what is happening are incorrect.

0
votes

I did try with uninstalling java 1.7 and installing the latest java 8 got solved my issue.