jcollum
jcollum

Reputation: 46579

cassandra 2 complaining about Java 7 when I have Java 7 installed

$ cassandra 
Cassandra 2.0 and later require Java 7 or later.

OK, what's going on in that part of the init script?

java_ver_output=`"${JAVA:-java}" -version 2>&1`

jvmver=`echo "$java_ver_output" | awk -F'"' 'NR==1 {print $2}'`
JVM_VERSION=${jvmver%_*}
JVM_PATCH_VERSION=${jvmver#*_}


if [ "$JVM_VERSION" \< "1.7" ] ; then
    echo "Cassandra 2.0 and later require Java 7 or later."
    exit 1;
fi

Hmm, if I get the version at the command line:

$ java_ver_output=`"${JAVA:-java}" -version 2>&1`

$ echo $java_ver_output
java version "1.7.0_55" Java(TM) SE Runtime Environment (build 1.7.0_55-b13) Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)

$ JVM_VERSION=${jvmver%_*}

$ echo $JVM_VERSION
1.7.0

If I run which java:

$ which java
/usr/bin/java

If I put that line in the script:

/usr/bin/java

The frustrating part here is that I've got this running in the past but since I bounced the server I can't get cassandra to start.

So I'm confused here, how is Cassandra confused about what version of Java I'm running? How do I get cassandra running? Is 1.7.0_55 not Java 7 (I don't get Java's naming convention)?

Upvotes: 2

Views: 9660

Answers (8)

Suman Bharadwaj
Suman Bharadwaj

Reputation: 11

Nothing above worked for me.I was trying to run cassandra with supervisor and was getting java error.So I figured out that I had to just set java path in cassandra.in.sh. I just had to set JAVA_HOME=/usr/local/jdk1.8.0_171 and save it and this worked for me.

Upvotes: 1

Jarl
Jarl

Reputation: 2861

This is caused by a bug in Cassandra: https://issues.apache.org/jira/browse/CASSANDRA-11661

Upvotes: 0

Alfredo Carrillo
Alfredo Carrillo

Reputation: 316

See this CASSANDRA-11716 issue. The solution posted there worked for me.

Upvotes: 1

John G
John G

Reputation: 1

There appears to be a newer issue now that Java 7 update 101 has been released. I installed this version which broke Cassandra:

yum install java-1.7.0-oracle-1.7.0.101-1jpp.1.el7.x86_64

Installing a previous version (update 99) fixed the issue:

yum install java-1.7.0-oracle-1.7.0.99-1jpp.1.el7.x86_64

I'm guessing somewhere in the cassandra startup script a Regex is written for 2 characters in the update version, not 3.

Upvotes: 0

Ali Sepehri.Kh
Ali Sepehri.Kh

Reputation: 2508

To resolve this problem I changed $JAVA_HOME environment variable to the path I found it from:

System Preferences -> Java -> java (tab in Java Control Panel) -> View -> Path

I had two version of java and the default one was the old version of java.

Upvotes: 1

ganesh kannan
ganesh kannan

Reputation: 61

I have faced a similar issue when installing DSE 4.6 on Linux. Issue is resolved when you set JAVA_HOME (as root) to the directory where JRE 1.7.x installed.

Upvotes: 0

user628904
user628904

Reputation: 746

I got the same error message when trying to start Cassandra. But I notised that I only got the error when starting Cassandra as root. It worked when I started Cassandra as my local user.

It turned out that java only was configured for my local user:

$ java -version
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)
$ sudo java -version
sudo: java: command not found

This fixed the problem:

Tell the system that you have JRE installed (update usr/local/java/jre1.7.0_60/bin/java to your current path):

$ sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jre1.7.0_60/bin/java" 1

Set the new JRE as default:

$ sudo update-alternatives --set java /usr/local/java/jre1.7.0_60/bin/java

Now java is installed for root and Cassandra can be started as root without the error message.

Upvotes: 8

Sully
Sully

Reputation: 14943

Per documentation: http://wiki.helioviewer.org/wiki/Apache_Cassandra_Installation

Set JAVA_HOME

Make sure JAVA_HOME is set: echo $JAVA_HOME

So make sure JAVA_HOME is pointing to /path/to/jdk7

Upvotes: 7

Related Questions