如何使用AmazonDynamoDB Local?

时间:2013-10-09 00:55:05

标签: amazon-web-services amazon-dynamodb

如何让AmazonDynamoDB Local的用户为我工作。尽管提供了所有配置信息,但我在服务器端和客户端超时时都会出错。


服务器


C:\Program Files (x86)\Java\jre7\bin>java -Djava.library.path=. -jar C:\Users\XXX\XXX\DynamoDB\dynamodb_loca
l_2013-09-12\DynamoDBLocal.jar --port 8888
2013-10-09 11:15:44.346:INFO:oejs.Server:jetty-8.y.z-SNAPSHOT
2013-10-09 11:15:44.413:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:8888
Oct 09, 2013 11:15:55 AM com.almworks.sqlite4java.Internal log
INFO: [sqlite] DB[1]: instantiated [XXXXXXXXXXXXXXXXX_us-east-1.db]
Oct 09, 2013 11:15:55 AM com.almworks.sqlite4java.Internal log
WARNING: [sqlite] cannot open DB[1]: com.almworks.sqlite4java.SQLiteException: [-91] cannot load library: java.lang.Unsa
tisfiedLinkError: no sqlite4java-win32-x86 in java.library.path
Oct 09, 2013 11:15:55 AM com.almworks.sqlite4java.Internal log
SEVERE: [sqlite] SQLiteQueue[AKIAIZR4RBNLFYSQQKAQ_us-east-1.db]: error running job queue
com.almworks.sqlite4java.SQLiteException: [-91] cannot load library: java.lang.UnsatisfiedLinkError: no sqlite4java-win3
2-x86 in java.library.path
at com.almworks.sqlite4java.SQLite.loadLibrary(SQLite.java:97)
at com.almworks.sqlite4java.SQLiteConnection.open0(SQLiteConnection.java:1314)
at com.almworks.sqlite4java.SQLiteConnection.open(SQLiteConnection.java:258)
at com.almworks.sqlite4java.SQLiteConnection.open(SQLiteConnection.java:269)
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.lang.Thread.run(Unknown Source)

引起:java.lang.UnsatisfiedLinkError:java.library.path中没有sqlite4java-win32-x86     at java.lang.ClassLoader.loadLibrary(Unknown Source)     at java.lang.Runtime.loadLibrary0(Unknown Source)     在java.lang.System.loadLibrary(未知来源)     在com.almworks.sqlite4java.Internal.tryLoadFromSystemPath(Internal.java:349)     在com.almworks.sqlite4java.Internal.loadLibraryX(Internal.java:124)     在com.almworks.sqlite4java.SQLite.loadLibrary(SQLite.java:95)     ... 9更多

Oct 09, 2013 11:15:55 AM com.almworks.sqlite4java.Internal log
WARNING: [sqlite] SQLiteQueue[XXXXXXXXXXXXXXXX_us-east-1.db]: stopped abnormally, reincarnating in 3000ms

客户端


class Program
{
    private static AmazonDynamoDBClient client;

    static void Main(string[] args)
    {
        CreateClient();

        CreateTablesUploadSampleItems(client);
    }

    private static void CreateClient()
    {
        var config = new AmazonDynamoDBConfig();
        config.ServiceURL = System.Configuration.ConfigurationManager.AppSettings["ServiceURL"];
        var accessKey = System.Configuration.ConfigurationManager.AppSettings["AWSAccessKey"];
        var secretAccessKey = System.Configuration.ConfigurationManager.AppSettings["AWSSecretKey"];
        client = new AmazonDynamoDBClient(accessKey, secretAccessKey, config);
    }
}

3 个答案:

答案 0 :(得分:4)

您需要运行java命令,以便-Djava.library.path引用解压缩Local DynamoDB软件包的路径。 .中的-Djava.library.path=.表示“当前目录”,应用程序需要能够在本地DynamoDB目录中加载本机SQLite库。

因此,您可以从本地DynamoDB目录中运行此命令:

java -Djava.library.path=. -jar DynamoDBLocal.jar

或者您必须提供两者的完整路径:

java -Djava.library.path=c:\path\to\dynamodb\ -jar c:\path\to\dynamodb\DynamoDBLocal.jar

答案 1 :(得分:0)

试试这个Maven插件,为您完成所有这些魔术:http://www.jcabi.com/jcabi-dynamodb-maven-plugin/index.html

答案 2 :(得分:0)

我知道这是一个旧请求,但是从那时起,我开始使用其他解决方案,例如localstack。我建议工程师使用localstack。可以通过调用docker来运行它!