【问题标题】:IBM Worklight - JSONStore fails to initialize after Direct UpdateIBM Worklight - JSONStore 在直接更新后无法初始化
【发布时间】:2014-07-01 01:15:26
【问题描述】:

我正在使用 Worklight 6.0.0.2 进行 Android 4.4“KitKit”中与 JSONStore 相关的修复。

除了一个问题外它工作正常:直接更新后应用程序重新启动,但 JSONStore 初始化失败;如果我们然后退出应用程序并重新启动,那么它运行良好。

在 android 4.4 中重现该问题的步骤。 “奇巧”:

  1. 触发直接更新
  2. 更新后允许应用自行启动

    然后你在 LogCat 中看到:

    05-13 16:28:57.010:E/jsonstore-core(16691):验证架构时出错 05-13 16:28:57.010: E/jsonstore-core(16691): java.lang.Throwable: 节点 名称为“_id”的架构中已存在 05-13 16:28:57.010: E/jsonstore 核心(16691):在 com.worklight.androidgap.jsonstore.database.DatabaseSchema.addNode(DatabaseSchema.java:124)

  3. 关闭应用程序。
  4. 重新启动它。

在 initoptions.js 中

var wlInitOptions = {
connectOnStartup : false,
heartBeatIntervalInSecs : 5,

logger : {
    enabled : true,
    level : 'debug',
    stringify : true,
    pretty : false,
    tag : {
        level : false,
        pkg : true
    },
    whitelist : [],
    blacklist : []
},
analytics : {
    enabled : false
},

};

内部JS文件:

 function wlCommonInit(){
     collections["Videos"] = {
     searchFields:{"BrandID":"string","VideoType":"string","CategoryID":"string","CourseID":"string","ISDeleted":"string","IsDownload":"string","VideoID":"string"}
        };
        var options = {"username":"*","password":"*","localKeyGen":false,"clear":false};

WL.JSONStore.init(collections, options)
        .then(function (resp) {
        Brands=WL.JSONStore.get('Brands');
        Categories=WL.JSONStore.get('Categories');
        Courses=WL.JSONStore.get('Courses');
        Videos=WL.JSONStore.get('Videos');
        Notification=WL.JSONStore.get('Notification');
        UserInformationColl = WL.JSONStore.get('UserInformation');
        BrandListCollection = WL.JSONStore.get('BrandList');
        VideosList = WL.JSONStore.get('VideoList');
        BusinessType= WL.JSONStore.get('BusinessType');

        connectToServer();
    //  initializeAnalytics(2000,131);

            var query={"IsDownload":"2"};
            WL.JSONStore.get('Videos').find(query, {exact:true})
            .then(function (result2) {
                if(result2.length > 0){
                    for(var i=0; i<result2.length; i++){
                        result2[i].json.IsDownload = 0;
                        Videos.replace(result2[i], {})
                        .then(function (numberOfDocumentsReplaced) {
                            WL.Logger.info("The number of document replaced are:--->"+numberOfDocumentsReplaced);
                        })

                        .fail(function (errorObject) {
                            WL.Logger.error("Error in document:---->"+errorObject);
                        });
                    }
                }
                errorvideodownloading();
            })
            .fail(function (errorObject) {
                WL.Logger.debug('error' +errorObject.toString());

            });
        })
        .fail(function (errorObject) {
             WL.Logger.error("init notification error:----->"+errorObject);
             if(errorObject.err === -2){
                 WL.Logger.error("In the errorObject so destroying JSON store and recreating it.");
                 WL.JSONStore.destroy();
                 JsonStoreinit();
                 localStorage.clear();
                 connectToServer();
            }
             else if(errorObject.err === 16)
             {
             hideSplashScreenPlatForm();
             } 
        });
}
else{
    WL.Logger.debug('[JSONStore] Check your dependencies.');

}
}catch(e){
     WL.Logger.error("Exception is:--->"+e);
}   

}

【问题讨论】:

  • Sram 请同时添加您的 JSONStore 初始化代码。
  • idan 请参考上面的代码。
  • 它的失败功能。
  • 直接更新成功执行后,JSONStore 代码是否会发生变化?例如:添加新的搜索字段,或删除现有的搜索字段,或将您的某个集合中的搜索字段的类型(例如 string 更改为 integer)。
  • 您能在另一个环境(例如 iOS)上尝试一下,然后让我知道会发生什么+日志吗?

标签: android ibm-mobilefirst jsonstore


【解决方案1】:

我不确定您的初始化代码。但是你会得到像

这样的错误
java.lang.Throwable: node with name "_id" already exists in schema 

当你在使用集合时直到成功回调。

更多信息请参见this 回答。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-04-07
    • 1970-01-01
    • 2013-08-13
    • 2015-02-16
    • 2013-12-01
    • 2018-06-30
    • 2014-01-06
    • 2015-02-20
    相关资源
    最近更新 更多