简体   繁体   English

IBM Worklight-直接更新后JSONStore无法初始化

[英]IBM Worklight - JSONStore fails to initialize after Direct Update

I am using Worklight 6.0.0.2 for JSONStore-related fixes in Android 4.4 "KitKit". 我将Worklight 6.0.0.2用于Android 4.4“ KitKit”中与JSONStore相关的修复。

It works fine except for one issue: after a Direct Update the application restarts but then the JSONStore initialization fails; 除一个问题外,它工作正常:直接更新后,应用程序重新启动,但是JSONStore初始化失败; if we then quit the application and relaunch then it works well. 如果我们然后退出该应用程序并重新启动,那么它将运行良好。

Steps for reproduction the issue in android 4.4. 在android 4.4中再现问题的步骤。 "KitKat": “奇巧”:

  1. Trigger a Direct Update 触发直接更新
  2. Allow application to launch it self after updating 允许应用程序在更新后自行启动

    Then you see in LogCat: 然后您会在LogCat中看到:

    05-13 16:28:57.010: E/jsonstore-core(16691): Error validating schema 05-13 16:28:57.010: E/jsonstore-core(16691): java.lang.Throwable: node with name "_id" already exists in schema 05-13 16:28:57.010: E/jsonstore-core(16691): at com.worklight.androidgap.jsonstore.database.DatabaseSchema.addNode(DatabaseSchema.java:124) 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-core(16691):位于com.worklight.androidgap.jsonstore.database.DatabaseSchema.addNode(DatabaseSchema.java:124)

  3. Close the application. 关闭应用程序。
  4. Relaunch it. 重新启动。

Inside initoptions.js 里面的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
},

}; };

Inside JS file: 里面的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);
}   

} }

Am not sure about your init Code. 不确定您的初始化代码。 But you will get error like 但是你会得到类似的错误

java.lang.Throwable: node with name "_id" already exists in schema 

when you are using the collection until a successful callback. 当您使用集合时,直到成功回调。

See this answer for more info. 有关更多信息,请参见此答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM