Dynamodb local setup on M1 apple silicon mac
Asked Answered
D

6

19

I did a local setup of dynamodb using https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.DownloadingAndRunning.html

I am able to start the instance using the following command java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb but when i try to do anything else it gives me the following error.

Mar 15, 2021 2:10:28 PM com.almworks.sqlite4java.Internal log WARNING: [sqlite] cannot open DB[15]: com.almworks.sqlite4java.SQLiteException: [-91] cannot load library: java.lang.UnsatisfiedLinkError: /Users/ahsanejaz/Downloads/dynamodb_local_latest/DynamoDBLocal_lib/libsqlite4java-osx.dylib: dlopen(/Users/ahsanejaz/Downloads/dynamodb_local_latest/DynamoDBLocal_lib/libsqlite4java-osx.dylib, 1): no suitable image found. Did find: /Users/ahsanejaz/Downloads/dynamodb_local_latest/DynamoDBLocal_lib/libsqlite4java-osx.dylib: no matching architecture in universal wrapper /Users/ahsanejaz/Downloads/dynamodb_local_latest/DynamoDBLocal_lib/libsqlite4java-osx.dylib: no matching architecture in universal wrapper Mar 15, 2021 2:10:28 PM com.almworks.sqlite4java.Internal log SEVERE: [sqlite] SQLiteQueue[shared-local-instance.db]: error running job queue com.almworks.sqlite4java.SQLiteException: [-91] cannot load library: java.lang.UnsatisfiedLinkError: /Users/ahsanejaz/Downloads/dynamodb_local_latest/DynamoDBLocal_lib/libsqlite4java-osx.dylib: dlopen(/Users/ahsanejaz/Downloads/dynamodb_local_latest/DynamoDBLocal_lib/libsqlite4java-osx.dylib, 1): no suitable image found. Did find: /Users/ahsanejaz/Downloads/dynamodb_local_latest/DynamoDBLocal_lib/libsqlite4java-osx.dylib: no matching architecture in universal wrapper /Users/ahsanejaz/Downloads/dynamodb_local_latest/DynamoDBLocal_lib/libsqlite4java-osx.dylib: no matching architecture in universal wrapper at com.almworks.sqlite4java.SQLite.loadLibrary(SQLite.java:97) at com.almworks.sqlite4java.SQLiteConnection.open0(SQLiteConnection.java:1441) at com.almworks.sqlite4java.SQLiteConnection.open(SQLiteConnection.java:282) at com.almworks.sqlite4java.SQLiteConnection.open(SQLiteConnection.java:293) at com.almworks.sqlite4java.SQLiteQueue.openConnection(SQLiteQueue.java:464) at com.almworks.sqlite4java.SQLiteQueue.queueFunction(SQLiteQueue.java:641) at com.almworks.sqlite4java.SQLiteQueue.runQueue(SQLiteQueue.java:623) at com.almworks.sqlite4java.SQLiteQueue.access$000(SQLiteQueue.java:77) at com.almworks.sqlite4java.SQLiteQueue$1.run(SQLiteQueue.java:205) at java.base/java.lang.Thread.run(Unknown Source) Caused by: java.lang.UnsatisfiedLinkError: /Users/ahsanejaz/Downloads/dynamodb_local_latest/DynamoDBLocal_lib/libsqlite4java-osx.dylib: dlopen(/Users/ahsanejaz/Downloads/dynamodb_local_latest/DynamoDBLocal_lib/libsqlite4java-osx.dylib, 1): no suitable image found. Did find: /Users/ahsanejaz/Downloads/dynamodb_local_latest/DynamoDBLocal_lib/libsqlite4java-osx.dylib: no matching architecture in universal wrapper /Users/ahsanejaz/Downloads/dynamodb_local_latest/DynamoDBLocal_lib/libsqlite4java-osx.dylib: no matching architecture in universal wrapper at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method) at java.base/java.lang.ClassLoader$NativeLibrary.load(Unknown Source) at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(Unknown Source) at java.base/java.lang.ClassLoader.loadLibrary0(Unknown Source) at java.base/java.lang.ClassLoader.loadLibrary(Unknown Source) at java.base/java.lang.Runtime.load0(Unknown Source) at java.base/java.lang.System.load(Unknown Source) at com.almworks.sqlite4java.Internal.tryLoadFromPath(Internal.java:340) at com.almworks.sqlite4java.Internal.loadLibraryX(Internal.java:117) at com.almworks.sqlite4java.SQLite.loadLibrary(SQLite.java:95) ... 9 more Mar 15, 2021 2:10:28 PM com.almworks.sqlite4java.Internal log WARNING: [sqlite] SQLiteQueue[shared-local-instance.db]: stopped abnormally, reincarnating in 3000ms

Is this issure related to new M1 Apple Silicon architecture? Any workaround for this?

Dickens answered 15/3, 2021 at 9:32 Comment(1)
The solution mentioned in here #73027472 solved my issue.Aframe
A
3

I had the same issue with dynamodb-local installed via brew. Apparently the sqlite4java lib being used does not have an arm version in there. Eg i get:

Caused by: java.lang.UnsatisfiedLinkError: /opt/homebrew/Caskroom/dynamodb-local/latest/DynamoDBLocal_lib/libsqlite4java-osx.dylib: dlopen(/opt/homebrew/Caskroom/dynamodb-local/latest/DynamoDBLocal_lib/libsqlite4java-osx.dylib, 1): no suitable image found.  Did find:
    /opt/homebrew/Caskroom/dynamodb-local/latest/DynamoDBLocal_lib/libsqlite4java-osx.dylib: no matching architecture in universal wrapper

Interestingly the docker image is working fine for me using the docker preview version, eg by using the docker compose file from Deploying DynamoDB Locally on Your Computer (on the Docker tab).

Aurilia answered 17/3, 2021 at 18:24 Comment(1)
Thank you, the docker image is working for me too.Dickens
E
14

You can use newly published Apple Silicon (M1) library. Adding this as a dependency into your project or if you are using a folder based approach copying this file into native libraries path should fix the error:

io.github.ganadist.sqlite4java:libsqlite4java-osx-aarch64:1.0.392

Direct download link: https://repo1.maven.org/maven2/io/github/ganadist/sqlite4java/libsqlite4java-osx-aarch64/1.0.392/libsqlite4java-osx-aarch64-1.0.392.dylib

You can specify custom native library path with sqlite4java.library.path system property:

# JVM parameter:
-Dsqlite4java.library.path=./native-libs
# or within source code:
System.setProperty("sqlite4java.library.path", "./native-libs")
Enteritis answered 4/2, 2022 at 14:14 Comment(4)
This worked perfectly well for me, just gave the old library a .old extension and removed the -aarch64 bit so that the name looks like the old library's name.Amharic
sqlite4java is usually looking into folder not a specific file. Meaning that if there are a few dylibs within same folder, it will use platform related one. But if library path points to a specific file, in that case maybe renaming library can help. Just wanted to point out folder reading behaviour :)Enteritis
I get Error while parsing options. Unrecognized option: -Dsqlite4java.library.path=~/native_librariesEnvision
Put the -Dsqlite... as the first parameter.Topographer
B
9

I was able to run DynamoDB installing a java version x86-64 architecture rather than arm64 and starting it up from a rosetta terminal

java --version 
openjdk 16.0.1 2021-04-20
OpenJDK Runtime Environment Zulu16.30+15-CA (build 16.0.1+9)
OpenJDK 64-Bit Server VM Zulu16.30+15-CA (build 16.0.1+9, mixed mode, sharing)

https://www.azul.com/downloads/zulu-community/?version=java-16-sts&os=macos&architecture=x86-64-bit&package=jre

Bonnes answered 8/5, 2021 at 2:31 Comment(4)
Essentially you create a Rosetta terminal osxdaily.com/2020/11/18/…. Then you install x86 64-bit Java. And you run your DynamoDB Local inside Rosetta terminal with x86 Java. You can connect to it via regular arm terminal.Dullish
When I installed the Intel x86 64-bit was possible to use locally too. Using ARM 64-bit I couldn't.Anabelanabella
I just ran into this problem on M1 macbook. Installing the official Java JDK for MacOS x64 fixed the problem.Garrett
Same as user @Garrett . Using Mac M1 with serverless and was getting above error. Installed Java JDK for MacOX x64 fixed it.Entirety
A
3

I had the same issue with dynamodb-local installed via brew. Apparently the sqlite4java lib being used does not have an arm version in there. Eg i get:

Caused by: java.lang.UnsatisfiedLinkError: /opt/homebrew/Caskroom/dynamodb-local/latest/DynamoDBLocal_lib/libsqlite4java-osx.dylib: dlopen(/opt/homebrew/Caskroom/dynamodb-local/latest/DynamoDBLocal_lib/libsqlite4java-osx.dylib, 1): no suitable image found.  Did find:
    /opt/homebrew/Caskroom/dynamodb-local/latest/DynamoDBLocal_lib/libsqlite4java-osx.dylib: no matching architecture in universal wrapper

Interestingly the docker image is working fine for me using the docker preview version, eg by using the docker compose file from Deploying DynamoDB Locally on Your Computer (on the Docker tab).

Aurilia answered 17/3, 2021 at 18:24 Comment(1)
Thank you, the docker image is working for me too.Dickens
M
3

When using Maven, simply add the following dependency:

<dependency>
  <groupId>io.github.ganadist.sqlite4java</groupId>
  <artifactId>libsqlite4java-osx-aarch64</artifactId>
  <version>1.0.392</version>
  <type>dylib</type>
  <scope>test</scope>
</dependency>

Note that com.almworks.sqlite4java has not been updated since 2014 so hopefully this will last until the AWS team will switch to another implementation.

Mapel answered 15/3, 2022 at 11:31 Comment(0)
E
1

Once you have docker installed can:

docker pull amazon/dynamodb-local:latest
docker run -p 8000:8000 amazon/dynamodb-local:latest

Another way to do it is to use a Docker container and just bind it to the same port you might usually bind it to for ARM architectures.

Ephrayim answered 21/3, 2022 at 16:31 Comment(0)
S
1

As of v1.20 DynamoDB Local works on M1 Macs without any extra libraries.

So if you are having this problem, you can likely upgrade rather then relying on third party libraries of uncertain trustworthiness.

Senhauser answered 19/4, 2023 at 7:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.