rynop / dynamodb-local

A wrapper for AWS DynamoDB Local, intended for use in testcases
MIT License
53 stars 30 forks source link

Error: Invalid or corrupt jarfile DynamoDBLocal.jar #30

Open jamesmorgan opened 5 years ago

jamesmorgan commented 5 years ago

I have a fairly simple test but when I try to use the package I get a corruption error, any ideas?

Sample code below:

const chai = require('chai');
chai.should();

const AWS = require('../../src/services/aws');

const DynamoDbLocal = require('dynamodb-local');
const dynamoLocalPort = 8000;

// optional config customization - default is your OS' temp directory and an Amazon server from US West
DynamoDbLocal.configureInstaller({
    installPath: './dynamodblocal-bin',
});

const VenuesService = require('../../src/services/venues.service');

describe.only('Venues Service test', () => {

    before(async () => {
        this.venuesService = new VenuesService(AWS);
        this.child = await DynamoDbLocal.launch(dynamoLocalPort, null, [], false, true);
        console.log(`Started Local DynamoDB - PID [${this.child.pid}]`);
    });

    after(async () => {
        await DynamoDbLocal.stopChild(this.child);
    });

    describe('a test', () => {
        it('should pass', async () => {
                const exampleVenue = require('../data/dummy_venue');
                await this.venuesService.createVenue(exampleVenue);
                done();
        });
    });

});

I see it downloading the jar to ./dynamodblocal-bin

Any ideas on this, what am I missing?

thanks in advance

praisegeek commented 5 years ago

Delete the folder .dynamodb on your project root folder then run sls dynamodb install again to download dependencies. Ensure it gets to 100%.

rfoel commented 4 years ago

Had the same problem on mac os. Reinstalling Java fixed for me.

AlessandroVol23 commented 4 years ago

I have the same problem on Mac OS as well. I tried the current jdk and jdk version 8. Reinstalling didn't help. Any suggestions?

AlessandroVol23 commented 4 years ago

Works with sudo yarn test. Sorry!

Do you know where the .DynamoDBLocal.jar file gets downloaded to?

djorg83 commented 4 years ago

I found the dynamodblocal installed in $TMPDIR

AlessandroVol23 commented 4 years ago

I found the dynamodblocal installed in $TMPDIR

Okay, I can't find it in there unfortunately. With sudo I can't watch the tests, so I'd like to change the access rights of the .DynamoDBLocal file but can't find it.

AlessandroVol23 commented 4 years ago

Okay it works now without sudo. No idea why, thanks anyway! :-)

Davidislit commented 4 years ago

I'm also encountered with this issue and this is the procedure I've done to solve it:

  1. download the jar manually (the url is from the package) https://s3-us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.tar.gz
  2. unzipped the tar file to the PATH: os.tmpdir() (you can simple execute this function in a simple script or via node cli)
  3. Changed the folder name to dynamodb-local
  4. sudo chmod 777 ./DynamoDBLocal.jar (the Jar is inside the folder)

This fixed my issue on my local machine.

emxqm-11 commented 4 years ago

@Davidislit Thanks that works. Originally i used sls dynamodb install but realised that /DynamoDBLocal_lib was completely empty and so was /third_party_licenses. I then downloaded the jar manually from your link. Copied the extracted contents into my project's /.dynomodb , sudo chmod the .jar and its running now.

visheshd commented 3 years ago

Using this on a private library without serverless ... I am on macOS Big Sur ... none of the workarounds work. Throws the same error.

sudarshan-plus commented 1 year ago

I guess it's an issue of the cloud region/zone, most probably.

johnou commented 8 months ago

%temp%\dynamodb-local on windows.

pablo-albaladejo commented 7 months ago

I solved the problem by deleting the directory /tmp/dynamodb-local on Linux For other operating systems, it's the one defined at https://github.com/rynop/dynamodb-local/blob/master/index.js#L17

zhaoyi0113 commented 7 months ago

I am facing the same issue on Mac. Where should I put the jar file?