Embedded Cassandra For Mac OS M1 Chip

97 Views Asked by At

I am trying to connect to embedded cassandra in mac Os M1 chip with Ventura Os

Cassandra Version: 3.11.14 Embedded Cassandra Version: 4.0.7

I am getting

Exception in thread "main" com.github.nosan.embedded.cassandra.CassandraException: Unable to start DefaultCassandra{name='cassandra-0', version='3.11.14'}. Caused by: java.io.FileNotFoundException: /var/folders/50/fwdzhkdd4zz_yn53s0szx2vw0000gq/T/apache-cassandra-6267611957967446273/bin/cassandra does not exist.

I tried to debug all the folders got created inside apache-cassandra-6267611957967446273 but bin folder was not created.

Help would be great.

Looking for help for fix

1

There are 1 best solutions below

0
Dmytro Nosan On

I was trying to run it today and what I got:

public class CassandraExample {

    public static void main(String[] args) {
        Cassandra cassandra = new CassandraBuilder()
                .addJvmOptions("-Xmx1024m", "-Xms1024m", "-Xss700k")
                .version("3.11.14")
                .build();

        cassandra.start();
        try {
            System.out.println(cassandra.getSettings().getPort());
        }
        finally {
            cassandra.stop();
        }
    }

}
ERROR [main] 2023-11-21 10:51:43,122 NativeLibraryDarwin.java:64 - Failed to link the C library against JNA. Native methods will be unavailable.
java.lang.UnsatisfiedLinkError: /private/var/folders/gq/64q79vjd4w16f9lzpl59mv8m0000gn/T/jna--1523686274/jna6880458316740657136.tmp: dlopen(/private/var/folders/gq/64q79vjd4w16f9lzpl59mv8m0000gn/T/jna--1523686274/jna6880458316740657136.tmp, 0x0001): tried: '/private/var/folders/gq/64q79vjd4w16f9lzpl59mv8m0000gn/T/jna--1523686274/jna6880458316740657136.tmp' (fat file, but missing compatible architecture (have 'i386,x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/private/var/folders/gq/64q79vjd4w16f9lzpl59mv8m0000gn/T/jna--1523686274/jna6880458316740657136.tmp' (no such file), '/private/var/folders/gq/64q79vjd4w16f9lzpl59mv8m0000gn/T/jna--1523686274/jna6880458316740657136.tmp' (fat file, but missing compatible architecture (have 'i386,x86_64', need 'arm64'))
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1950)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1832)
    at java.lang.Runtime.load0(Runtime.java:811)
    at java.lang.System.load(System.java:1088)
    at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:851)
    at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:826)
    at com.sun.jna.Native.<clinit>(Native.java:140)
    at com.sun.jna.NativeLibrary.<clinit>(NativeLibrary.java:84)
    at org.apache.cassandra.utils.NativeLibraryDarwin.<clinit>(NativeLibraryDarwin.java:55)
    at org.apache.cassandra.utils.NativeLibrary.<clinit>(NativeLibrary.java:90)
    at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:212)
    at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:633)
    at org.apache.cassandra.service.CassandraDaemon.main(CassandraDaemon.java:786)
WARN  [main] 2023-11-21 10:51:43,123 StartupChecks.java:136 - jemalloc shared library could not be preloaded to speed up memory allocations
WARN  [main] 2023-11-21 10:51:43,123 StartupChecks.java:169 - JMX is not enabled to receive remote connections. Please see cassandra-env.sh for more info.
ERROR [main] 2023-11-21 10:51:43,124 CassandraDaemon.java:803 - The native library could not be initialized properly. 
    at com.github.nosan.embedded.cassandra.DefaultCassandra.await(DefaultCassandra.java:235)
    ... 2 more

Are you sure that Apache Cassandra 3.11.14 supports M1 chip?

Regarding your question about FileNotFoundException, looks like something is wrong with downloaded files.

Could you clean up ~/.embedded-cassandra directory and try again, please?

UPDATE:

If you still want to run 3.11.14 version on M1, then you can try:


public class CassandraExample {

    public static void main(String[] args) {
        Path lib = Paths.get("jna-5.9.0.jar");
        Cassandra cassandra = new CassandraBuilder()
                .addJvmOptions("-Xmx1024m", "-Xms1024m", "-Xss700k")
                .addWorkingDirectoryCustomizers((workingDirectory, version) -> {
                    FileUtils.delete(workingDirectory.resolve("lib/jna-4.2.2.jar"));
                })
                .addWorkingDirectoryCustomizers(
                        WorkingDirectoryCustomizer.addResource(new FileSystemResource(lib), "lib/jna-5.9.0.jar"))
                .version("3.11.14")
                .build();

        cassandra.start();
        try {
            System.out.println(cassandra.getWorkingDirectory());
        }
        finally {
            cassandra.stop();
        }
    }

}

But you need to download jna-5.9.0.jar library. https://mvnrepository.com/artifact/net.java.dev.jna/jna/5.9.0