Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cassandra Could not initialize class com.sun.jna.Native

I am having Cassandra version 3.9 on CentOS 7. While starting Cassandra Server, I'm getting error like this::

TRACE [MemtableFlushWriter:1] 2017-05-15 04:25:49,735 LogTransaction.java:264 - Closing transaction log [mc_txn_flush_3f6a46f0-3961-11e7-87b4-0728ea39fb0d.log in /var/lib/cassandra/data/system/local-7ad54392bcdd35a684174e047860b377]
ERROR [main] 2017-05-15 04:25:49,745 CassandraDaemon.java:747 - Exception encountered during startup java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: Could not initialize class com.sun.jna.Native at org.apache.cassandra.utils.FBUtilities.waitOnFuture(FBUtilities.java:403) ~[apache-cassandra-3.9.0.jar:3.9.0] at org.apache.cassandra.db.SystemKeyspace.forceBlockingFlush(SystemKeyspace.java:793) ~[apache-cassandra-3.9.0.jar:3.9.0] at org.apache.cassandra.db.SystemKeyspace.removeTruncationRecord(SystemKeyspace.java:639) ~[apache-cassandra-3.9.0.jar:3.9.0] at org.apache.cassandra.db.ColumnFamilyStore.invalidate(ColumnFamilyStore.java:541) ~[apache-cassandra-3.9.0.jar:3.9.0] at org.apache.cassandra.db.ColumnFamilyStore.invalidate(ColumnFamilyStore.java:517) ~[apache-cassandra-3.9.0.jar:3.9.0] at org.apache.cassandra.schema.LegacySchemaMigrator.lambda$unloadLegacySchemaTables$341(LegacySchemaMigrator.java:137) ~[apache-cassandra-3.9.0.jar:3.9.0] at org.apache.cassandra.schema.LegacySchemaMigrator$$Lambda$93/1308179535.accept(Unknown Source) ~[na:na] at java.lang.Iterable.forEach(Iterable.java:75) ~[na:1.8.0_45] at org.apache.cassandra.schema.LegacySchemaMigrator.unloadLegacySchemaTables(LegacySchemaMigrator.java:137) ~[apache-cassandra-3.9.0.jar:3.9.0] at org.apache.cassandra.schema.LegacySchemaMigrator.migrate(LegacySchemaMigrator.java:83) ~[apache-cassandra-3.9.0.jar:3.9.0] at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:254) [apache-cassandra-3.9.0.jar:3.9.0] at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:601) [apache-cassandra-3.9.0.jar:3.9.0] at org.apache.cassandra.service.CassandraDaemon.main(CassandraDaemon.java:730) [apache-cassandra-3.9.0.jar:3.9.0]

There is a solution to this problem (Cassandra Startup failure on ARM64 machine (java.lang.NoClassDefFoundError: Could not initialize class com.sun.jna.Native) ), Soultion suggests changes in cassandra-env.sh. I tried it but it is not working for me.

I checked with these options (separately) in cassandra-env.sh

JVM_OPTS="$JVM_OPTS -Djava.io.tmpdir=/home/tech/cassandra/tmp"
JVM_OPTS="$JVM_OPTS -Djava.io.tmpdir=/home/cassandra/tmp"
JVM_OPTS="$JVM_OPTS -Djava.io.tmpdir=/var/lib/cassandra/tmp"

even tried with

JVM_OPTS="$JVM_OPTS -Dcassandra.boot_without_jna=true"

But no change in the problem.

And I changed cassandra logger to TRACE, but it is showing the same error log as before there was no TRACE. The file(jna-4.0.0.jar) is present in lib folder (/usr/share/cassandra/lib). I am unable to find what the actual reason is.

The reasons for not working for me are like:

  1. cassandra-env.sh is loaded by server. (If it loading how do I check, whether it is loaded or not)

  2. There might be some other problem.

Someone, Please let me out from this.

like image 274
chikku Avatar asked May 15 '17 12:05

chikku


People also ask

How to resolve 'could not initialize Class Com JNA native' error?

This article describes how to resolve the "Could not initialize class com.sun.jna.Native" error, occurring during Cassandra startup. Cassandra database throws the following exception while starting: ... This issue is typically caused by a noexec flag set on the temporary directory. 1. Remount tmp directory without noexec flag 2.

What are the common errors in Cassandra?

The error occurs on the Cassandra database startup. Cassandra throws the following exception while starting: ERROR o.a.c.service.CassandraDaemon - Exception in thread Thread [MemtableFlushWriter:1,5,main] java.lang.NoClassDefFoundError: Could not initialize class com.sun.jna.Native

Is there a solution for Cassandra startup failure on ARM64?

There is a solution to this problem ( Cassandra Startup failure on ARM64 machine (java.lang.NoClassDefFoundError: Could not initialize class com.sun.jna.Native) ), Soultion suggests changes in cassandra-env.sh. I tried it but it is not working for me.

What are the exceptions thrown by Cassandra?

Cassandra throws the following exception while starting: ERROR o.a.c.service.CassandraDaemon - Exception in thread Thread [MemtableFlushWriter:1,5,main] java.lang.NoClassDefFoundError: Could not initialize class com.sun.jna.Native


2 Answers

Finally the problem with jna-4.0.0.jar.

The file jna-4.0.0.jar in lib is not initializing, so I changed the file by creating symbolic link to jna.jar.

sudo yum install jna

sudo ln -s (JAVA_PATH)/usr/share/java/jna.jar (CASSANDRA_PATH)/usr/share/cassandra/lib

Then It produced some errors regarding tmp, solved with previous solutions.

Regarding JNA, there are already some questions over there, but those are not specific.

like image 184
chikku Avatar answered Sep 30 '22 05:09

chikku


I faced the same problem. Clean up (rm -rf *) of the /tmp folder or the folder which '-Djava.io.tmpdir' points to

like image 41
Vinod Jayachandran Avatar answered Sep 30 '22 04:09

Vinod Jayachandran