4

When I run the command $ nodetool help I get the following error;

java.lang.NullPointerException
  at org.apache.cassandra.config.DatabaseDescriptor.getDiskFailurePolicy(DatabaseDescriptor.java:1877)
  at org.apache.cassandra.utils.JVMStabilityInspector.inspectThrowable(JVMStabilityInspector.java:62)
  at org.apache.cassandra.io.util.FileUtils.<clinit>(FileUtils.java:79)
  at org.apache.cassandra.utils.FBUtilities.getToolsOutputDirectory(FBUtilities.java:807)
  at org.apache.cassandra.tools.NodeTool.printHistory(NodeTool.java:199)
  at org.apache.cassandra.tools.NodeTool.main(NodeTool.java:167)

Please let me know if anyone has any tips.

Payal Zilaro
  • 41
  • 1
  • 3

4 Answers4

7

I've got the same error.

I suggest you too use java 7 or 8 (not tested 7), and not java 9 or 10.

$ java -version # java 8

java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)

$ java --version # java 9

java 9.0.4
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)

$ nodetool # java 9

error: null
-- StackTrace --
java.lang.NullPointerException
    at org.apache.cassandra.config.DatabaseDescriptor.getDiskFailurePolicy(DatabaseDescriptor.java:1881)
    at org.apache.cassandra.utils.JVMStabilityInspector.inspectThrowable(JVMStabilityInspector.java:82)
    at org.apache.cassandra.io.util.FileUtils.<clinit>(FileUtils.java:79)
    at org.apache.cassandra.utils.FBUtilities.getToolsOutputDirectory(FBUtilities.java:788)
    at org.apache.cassandra.tools.NodeTool.printHistory(NodeTool.java:200)
    at org.apache.cassandra.tools.NodeTool.main(NodeTool.java:168)

I assume cassandra code try to parse java version somewhere and don't handle lastest java versions

5

I could solve it on Ubuntu 18.4 by downgrading the default java version version:

sudo update-alternatives --config java

The output should look like:

  Selection    Path                                            Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      manual mode
* 2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode

Now just choose java version 8. You can try if everything worked with java -version.

PeMa
  • 1,559
  • 18
  • 44
3

I got the very same error, but you can workaround it with specifiing the config explictely:

JAVA_HOME="/opt/java/my-java"
PATH="$JAVA_HOME/bin:$PATH"

# run the node tool
CASSANDRA_CONF=/path/tocassandra/conf.d \
  JAVA_TOOL_OPTIONS= \
  JAVA_HOME=/opt/java/my-java \
  ./bin/nodetool status

HTH

Benjamin Marwell
  • 1,173
  • 1
  • 13
  • 36
  • 1
    Amazing! I would also like to add that the proper script to override JVM would be '/usr/share/cassandra/cassandra.in.sh' as of Cassandra 3.11.4 on Ubuntu Bionic. Thanks mate! – Kamyar Apr 19 '19 at 19:30
  • What was the java version you were using? Tried with java 13 and got the same error. Cassandra 4.x will add java 11 compatibility, but for now just can't use nodetool. – Leonardo Goes Nov 30 '19 at 22:15
  • I used adoptopenjdk-openj9. I think only hotspot VMs are supported at the moment. You could try one of those (Oracle openjdk. adoptopenjdk-hotspot, Amazon Corretto, etc.). – Benjamin Marwell Dec 02 '19 at 07:56
-2

If you want to run help command then move to the bin directory of Cassandra, then run following command -

./nodetool help
Dipesh Yadav
  • 2,353
  • 1
  • 14
  • 9