Payal Zilaro
Payal Zilaro

Reputation: 51

Cassandra nodetool java.lang.NullPointerException

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.

Upvotes: 5

Views: 7441

Answers (4)

PeMa
PeMa

Reputation: 1716

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.

Upvotes: 5

Benjamin Marwell
Benjamin Marwell

Reputation: 1246

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

Upvotes: 3

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

Upvotes: 7

Dipesh Yadav
Dipesh Yadav

Reputation: 2857

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

./nodetool help

Upvotes: -2

Related Questions