Note: For up-to-date product documentation, see the IBM MobileFirst Foundation Developer Center.

JSONStore troubleshooting overview

Find information to help resolve issues that you might encounter when you use the JSONStore API.

Provide information when you ask for help

It is better to provide more information than to risk not providing enough information. The following list is a good starting point for the information that is required to help with JSONStore issues.
  • Operating system and version. For example, Windows XP SP3 Virtual Machine or Mac OSX 10.8.3.
  • Eclipse version. For example, Eclipse Indigo 3.7 Java™ EE.
  • JDK version. For example, Java SE Runtime Environment (build 1.7).
  • IBM MobileFirst™ Platform Foundation version. For example, IBM® Worklight® V5.0.6 Developer Edition.
  • iOS version. For example, iOS Simulator 6.1 or iPhone 4S iOS 6.0 (deprecated, see Deprecated features and API elements).
  • Android version. For example, Android Emulator 4.1.1 or Samsung Galaxy Android 4.0 API Level 14.
  • Windows version. For example, Windows 8, Windows 8.1, or Windows Phone 8.1.
  • adb version. For example, Android Debug Bridge version 1.0.31.
  • Logs, such as Xcode output on iOS or logcat output on Android.

Try to isolate the issue

Follow these steps to isolate the issue to more accurately report a problem.
  1. Reset the emulator (Android) or simulator (iOS) and call the destroy API to start with a clean system.
  2. Ensure that you are running on a supported production environment.
    • Android >= 2.3 ARM v7/ARM v8/x86 emulator or device
    • iOS >= 6.0 simulator or device (deprecated)
    • Windows Phone Silverlight 8.0 ARM/x86 emulator or device
    • Windows 8.0-8.1 ARM/x86/x64 simulator or device
  3. Try to turn off encryption by not passing a password to the init or open APIs.
  4. Look at the SQLite database file that is generated by JSONStore. Encryption must be turned off.
    • Android emulator:
      $ adb shell
      $ cd /data/data/com.<app-name>/databases/wljsonstore
      $ sqlite3 jsonstore.sqlite
    • iOS simulator:
      $ cd ~/Library/Application Support/iPhone Simulator/7.1/Applications/<id>/Documents/wljsonstore
      $ sqlite3 jsonstore.sqlite
    • Windows Phone Silverlight 8:
      $ cd C:\Data\Users\DefApps\AppData\<id>\Local\wljsonstore
      $ sqlite3 jsonstore.sqlite
    • Windows 8 Universal simulator
      $ cd C:\Users\<username>\AppData\Local\Packages\<id>\LocalState\wljsonstore
      $ sqlite3 jsonstore.sqlite
    • Note: JavaScript only implementation that runs on a web browser (Firefox, Chrome, Safari, Internet Explorer) does not use an SQLite database. The file is stores in HTML5 LocalStorage.
    • Look at the searchFields with .schema and select data with SELECT * FROM <collection-name>;. To exit sqlite3, type .exit. If you pass a user name to the init method, the file is called <username>.sqlite. If you do not pass a user name, the file is called jsonstore.sqlite by default.
  5. (Android only) Enable verbose JSONStore.
    adb shell setprop log.tag.jsonstore-core VERBOSE
    adb shell getprop log.tag.jsonstore-core
  6. Use the debugger.

Common issues

Understanding the following JSONStore characteristics can help resolve some of the common issues that you might encounter.
  • The only way to store binary data in JSONStore is to first encode it in base64. Store file names or paths instead of the actual files in JSONStore.
  • Accessing JSONStore data from native code is possible only in IBM MobileFirst Platform Foundation V6.2.0.
  • There is no limit on how much data you can store inside JSONStore, beyond limits that are imposed by the mobile operating system.
  • JSONStore provides persistent data storage. It is not only stored in memory.
  • The init API fails when the collection name starts with a digit or symbol. IBM Worklight V5.0.6.1 and later returns an appropriate error:
    4 BAD_PARAMETER_EXPECTED_ALPHANUMERIC_STRING
  • There is a difference between a number and an integer in search fields. Numeric values like 1 and 2 are stored as 1.0 and 2.0 when the type is number. They are stored as 1 and 2 when the type is integer.
  • If an application is forced to stop or crashes, it always fails with error code -1 when the application is started again and the init or open API is called. If this problem happens, call the closeAll API first.
  • The JavaScript implementation of JSONStore expects code to be called serially. Wait for an operation to finish before you call the next one.
  • Transactions are not supported in Android 2.3.x for Cordova applications. For more information, see JSONStore API concepts.
  • When you use JSONStore on a 64-bit device, you might see the following error:
    java.lang.UnsatisfiedLinkError: dlopen failed: "..." is 32-bit instead of 64-bit
    This error means that you have 64-bit native libraries in your Android project, and JSONStore does not currently work when you use these libraries. To confirm, go to src/main/libs or src/main/jniLibs under your Android project, and check whether you have the x86_64 or arm64-v8a folders. If you do, delete these folders, and JSONStore can work again.