I am creating an inMemory dynamoDB locally with com.amazonaws' dynamodblocal (v 1.10.5.1 from maven).
Java code to start the local server is:
server = ServerRunner.createServerFromCommandLineArgs({ "port", getAvailablePort(), "-inMemory", "-sharedDb" });
server.start();
AmazonDynamoDBClient amazonDynamoDBClient = new AmazonDynamoDBClient(basicAWSCredentials);
Here is the log confirming I have successfully started a local dynamodb:
Initializing DynamoDB Local with the following configuration:
Port: 60677
InMemory: true
DbPath: null
SharedDb: true
shouldDelayTransientStatuses: false
CorsParams: *
Port 60677 is used here and I can manually open up http://localhost:60677/shell
from a web browser. But it doesn't work when I try to reach it programmatically. I keep getting HTTP/1.1 500 Server Error
.
This would give me 500 Error (port would be the output of getAvailablePort()
):
amazonDynamoDBClient.setEndpoint("http://localhost:" + port);
amazonDynamoDBClient.listTables();
Also when I start one from the command line with:
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -port 9999 -inMemory -sharedDb
and try to connect to it programmatically, it works fine. It allows me do all CRUD operations programmatically.
What am I doing wrong?