17

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?

Ahsan Ejaz
  • 173
  • 1
  • 1
  • 5
  • The solution mentioned in here https://stackoverflow.com/questions/73026972/serverless-dynamodb-start-migrate-error/73026973#73026973?newreg=1c588ac27ba44fc5a5484c4cee6ecd7a solved my issue. – Pablo Ezequiel Leone Sep 29 '22 at 08:34

6 Answers6

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")
veysiertekin
  • 1,731
  • 2
  • 15
  • 40
  • 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. – Punter Bad Mar 08 '22 at 10:43
  • `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 :) – veysiertekin Mar 28 '22 at 15:22
  • I get `Error while parsing options. Unrecognized option: -Dsqlite4java.library.path=~/native_libraries` – vamsiampolu May 06 '22 at 09:04
  • Put the -Dsqlite... as the first parameter. – Philip Callender May 28 '22 at 12:45
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

  • Essentially you create a Rosetta terminal https://osxdaily.com/2020/11/18/how-run-homebrew-x86-terminal-apple-silicon-mac/. 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. – Katafalkas Jul 23 '21 at 07:37
  • 1
    When I installed the Intel `x86 64-bit` was possible to use locally too. Using ARM 64-bit I couldn't. – Tiago Boeing Aug 12 '21 at 11:10
  • 3
    I just ran into this problem on M1 macbook. Installing the official Java JDK for MacOS x64 fixed the problem. – C.D. Jan 10 '22 at 21:43
  • 1
    Same as user @C.D. . Using Mac M1 with serverless and was getting above error. Installed Java JDK for MacOX x64 fixed it. – Sudhakar Jan 12 '22 at 05:07
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).

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.

Ben Romberg
  • 705
  • 8
  • 8
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.

justin lin
  • 11
  • 1
0

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.

Gareth
  • 503
  • 4
  • 9