Topic
10 replies Latest Post - ‏2013-01-24T20:27:38Z by SystemAdmin
SystemAdmin
SystemAdmin
2327 Posts
ACCEPTED ANSWER

Pinned topic key must not be null ???

‏2013-01-23T11:58:16Z |
I am testing a new app in Version: 5.0.0, Build ID: IWSO50-I20120608_0003 and am testing on a USB attached Nexus 7 running Android 4.2.1 using the server integrated into the Worklight Development environment. I am able to deploy the app to the tablet to test, however if I attempt to update the app, or close the app and restart it, I get a "key must not be null" error. The relevant part of the Android trace on failure is:
01-23 06:41:13.002: D/IBMSolutions(28937): Request http://192.168.1.52:8080/apps/services/api/IBMSolutions/android/init
01-23 06:41:13.122: D/IBMSolutions(28937): Request http://192.168.1.52:8080/apps/services/api/IBMSolutions/android/init
01-23 06:41:13.232: D/IBMSolutions(28937): Request http://192.168.1.52:8080/apps/services/api/IBMSolutions/android/init
01-23 06:41:13.352: E/IBMSolutions(28937): http://192.168.1.52:8080/apps/services/api/IBMSolutions/android/init failure. state: 500, response: key must not be null
01-23 06:41:13.382: E/IBMSolutions(28937): Client init failed. key must not be null

The Android has wifi enabled and the server and tablet are on the same router. The message displayed on the tablet is identical and shows:
Error Code: UNEXPECTED_ERROR
Error Message: key must not be null
HTTP Status: 500

Can you help me figure out the problem?
  • IdanAdar
    IdanAdar
    741 Posts
    ACCEPTED ANSWER

    Re: ley must not be null ???

    ‏2013-01-24T07:39:44Z  in response to SystemAdmin
    Hi,

    In our testing we have yet to encounter this issue.
    I see that you are using IBM Worklight 5.0; can you please try upgrading to IBM Worklight 5.0.5.1 (latest version) and try again?

    Idan Adar
    QA Engineer
    IBM Worklight Mobile Platform
    • SystemAdmin
      SystemAdmin
      2327 Posts
      ACCEPTED ANSWER

      Re: ley must not be null ???

      ‏2013-01-24T12:51:01Z  in response to IdanAdar
      I've uncovered the apparent root of the issue. I normally have a VPN connection up all the time, so my windows 7 environment has two IP addresses, one for the local (real) address and one for the VPN. If I use the Worklight default settings, the Worklight server always picks up my VPN ip address. This causes testing against a locally installed DB to fail consistent. So, I specified in the worklight properties to use either my local ip address or localhost and specified in the application properties xml file the local ip address. This enables the local DB queries to work. However, it also causes the key must not be null error to occur. There's apparently a path issue that's not apparent here.

      Workaround:
      (1) comment out the host specification in worklight properties (go back to default setting)
      (2) leave correct local IP address in application properties xml file
      (3) stop VPN
      (4) stop worklight server if running.
      (5) restart worklight server with VPN NOT RUNNING. This forces the server to start with the correct, local ip address of the dev workstation

      Unfortunately, Worklight dev gets REALLY CONFUSED when there's a VPN running on the dev workstation. I could use some help figuring out how to test and have my VPN up at the same time. Using the AT&T VPN.

      I did attempt to run the same app on the latest version of Worklight, however there appear to be API incompatibilities between the 5.0.0 and 5.0.5 ... I don't have time to rewrite the app to run with 5.0.5.
      • SystemAdmin
        SystemAdmin
        2327 Posts
        ACCEPTED ANSWER

        Re: ley must not be null ???

        ‏2013-01-24T13:00:16Z  in response to SystemAdmin
        Scratch that part about it working now. Still doesn't work, with or without the VPN running. Appears to be associated with the definition of a specific IP address for the app. getting desperate for help.
        thanks,
  • IdanAdar
    IdanAdar
    741 Posts
    ACCEPTED ANSWER

    Re: ley must not be null ???

    ‏2013-01-24T13:50:35Z  in response to SystemAdmin
    Bob,

    How about not touching anything in worklight.properties (keep it default), but rather change the value of worklightServerRootURL in application-descriptor.xml to the correct IP address; this value tells the client (app) the IP address of the Worklight Server to connect to.

    Idan Adar
    QA Engineer
    IBM Worklight Mobile Platform
    • SystemAdmin
      SystemAdmin
      2327 Posts
      ACCEPTED ANSWER

      Re: ley must not be null ???

      ‏2013-01-24T16:48:23Z  in response to IdanAdar
      OK. I've gotten this to a repeatable error in a brand new worklight app. The app is set up so that it dynamically loads a page fragement on initial application load. That works just fine over multiple changes, this is just for context.

      In the page fragment load process, I check to see if this is the first time that the application has been loaded on this device by executing the following code:
      1) var bdSelect;
      2) bdSelect = WL.Client.getUserPref("FirstTime");
      3) WL.Logger.debug("homePage::init bdSelect = " +bdSelect);
      4) if (bdSelect == null)
      5) {
      6) document.getElementById("updates").innerHTML = "<hr>Welcome to IBM Solutions. Please use the options button to create an initial profile for yourself. <hr>";
      7) WL.Client.setUserPref("FirstTime","false");
      8) }

      If I just execute the first two lines and have lines 4-8 (the if clause) commented out. no problems on multiple iterations. Once I execute the if clause for the first time, however, the app fails every time on update with the "key must not be null" error. Additionally, once I end the app on the Android tablet, it becomes inoperable with the same error displayed on the tablet during the initialization process. The issue therefore has something to do with the getUserPref/setUserPref process.

      If I should be using a different approach to address question of first-time load, please advise. This is a show-stopper for me right now.

      thanks for your time and insights,
  • IdanAdar
    IdanAdar
    741 Posts
    ACCEPTED ANSWER

    Re: ley must not be null ???

    ‏2013-01-24T17:07:49Z  in response to SystemAdmin
    Right, this is then a bit more context about what is going on...

    I don't have a full solution for you, but since the error says that key cannot be null, and you are checking for null then perhaps you should change what you are checking for.
    Maybe after the user logs in, you should change the key from FirstTime to something else, and then check for which key the user has now, upon the next log in.

    Idan Adar
    QA Engineer
    IBM Worklight Mobile Platform
    • SystemAdmin
      SystemAdmin
      2327 Posts
      ACCEPTED ANSWER

      Re: ley must not be null ???

      ‏2013-01-24T17:36:15Z  in response to IdanAdar
      Idan - thanks. At this point, I've found that I have to disable all of the setUserPref statements in the app that occur during initialization. Other server access, such as SQL queries during initialization, run without error. At this point, I have a work-around (don't set userprefs during initialization). I don't like it, but perhaps there are limitations on the ability to set user preferences during app startup.
      • SystemAdmin
        SystemAdmin
        2327 Posts
        ACCEPTED ANSWER

        Re: ley must not be null ???

        ‏2013-01-24T19:29:46Z  in response to SystemAdmin
        Where are you putting your setUserPref statements? I tried to put one in wlCommonInit and I'm not seeing any error.
        • SystemAdmin
          SystemAdmin
          2327 Posts
          ACCEPTED ANSWER

          Re: ley must not be null ???

          ‏2013-01-24T19:31:16Z  in response to SystemAdmin
          However I am using 5.0.5.1... but I would like to make sure I'm at least replicating your scenario.
          • SystemAdmin
            SystemAdmin
            2327 Posts
            ACCEPTED ANSWER

            Re: ley must not be null ???

            ‏2013-01-24T20:27:38Z  in response to SystemAdmin
            The attached zip has everything from the app directory except for the android folder. Everything is in "common", however I test on an Android Nexus 7. Did not include Android folder as it adds another 4.5M to the zip. No modifications were made to content under the android folder. Worklight Properties is in default setting.