Cassandra nodetool java.lang.NullPointerException
Asked Answered
U

4

5

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.

Unprofitable answered 10/1, 2018 at 18:30 Comment(4)
It would help if you could at least specify the Cassandra version you're usingClarion
are you using the same version of nodetool that ships with the C* you are running?Mixologist
Never mind. I was running the command locally. I had someone ssh into the cluster and it workedUnprofitable
@PayalZilaro Please add your answer below so this isn't shown as an open question.Detest
K
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

Kathaleenkatharevusa answered 13/6, 2018 at 14:36 Comment(0)
G
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.

Gorilla answered 29/9, 2019 at 16:5 Comment(0)
F
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

Flypaper answered 4/2, 2019 at 8:56 Comment(3)
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!Longsufferance
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.Digraph
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.).Flypaper
P
-2

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

./nodetool help
Paediatrician answered 21/2, 2018 at 5:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.