mfp cli build: missing cordova on preview

666 Views Asked by At

When building using the CLI, everything seems to work OK, until I look at the console in for the preview, then I see that there are some missing files. Here's the console output:

Android:

Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.
GET http://localhost:10080/MyProject/apps/services/preview/MyApp/android/1.0/default/cordova/cordovasim.js 404 (Not Found)_mbs_cordova_sim_load_js @ cordova.js:21(anonymous function) @ cordova.js:53
worklight.js:5138 Uncaught Exception: Uncaught ReferenceError: cordova is not defined at (compiled_code):16156WL.Logger.__log @ worklight.js:5138WL.Logger.$.each.PUBLIC_API.(anonymous function) @ worklight.js:5520WL.Logger.window.onerror @ worklight.js:5478
worklight.js:16156 Uncaught ReferenceError: cordova is not defined(anonymous function) @ worklight.js:16156
worklight.js:5134 Initialization option 'connectOnStartup' is deprecated. Use WL.Client.connect() to connect to the IBM MobileFirst Platform Server.
worklight.js:5134 wlclient init started
dependencies.js:10 WL not defined ReferenceError: cordova is not defined
    at klass.WL.BusyIndicator.WLJSX.Class.create.show (http://localhost:10080/MyProject/apps/services/preview/MyApp/android/1.0/default/worklight/worklight.js:12157:6)
    at __showBusy (http://localhost:10080/MyProject/apps/services/preview/MyApp/android/1.0/default/worklight/worklight.js:7345:18)
    at onEnvInit (http://localhost:10080/MyProject/apps/services/preview/MyApp/android/1.0/default/worklight/worklight.js:7660:14)
    at init (http://localhost:10080/MyProject/apps/services/preview/MyApp/android/1.0/default/worklight/worklight.js:8128:4)
    at http://localhost:10080/MyProject/apps/services/preview/MyApp/android/1.0/default/assets/js/dependencies.js:10:990(anonymous function) @ dependencies.js:10
angular-libs.js:8 [10:40:49]MyApp.home.controller :: [INFO] Welcome to MyApp

iPhone:

    http://localhost:10080/MyProject/apps/services/preview/MyApp/iphone/1.0/default/worklight/cordova.js Failed to load resource: the server responded with a status of 404 (Not Found)_mbs_cordova_sim_load_js @ cordova.js:21
    cordova.js:26 Uncaught ReferenceError: cordova is not defined
    worklight.js:5134 Initialization option 'connectOnStartup' is deprecated. Use WL.Client.connect() to connect to the IBM MobileFirst Platform Server.
    worklight.js:5134 wlclient init started
    worklight.js:5134 Request [/MyProject/apps/services/api/MyApp/iphone/init]
    worklight.js:5134 Application details header: {"applicationDetails":{"platformVersion":"7.0.0.0","nativeVersion":"1161280635"}}WL.Logger.__log @ worklight.js:5134
    http://localhost:10080/MyProject/apps/services/api/MyApp/iphone/init Failed to load resource: the server responded with a status of 401 (Unauthorized)
    worklight.js:5134 Application details header: {"applicationDetails":{"platformVersion":"7.0.0.0","nativeVersion":"1161280635"}}WL.Logger.__log @ worklight.js:5134
    worklight.js:5134 Request [/MyProject/apps/services/api/MyApp/iphone/init]
    angular-libs.js:8 [10:38:54]MyApp.home.controller :: [INFO] Welcome to MyApp
    http://localhost:10080/favicon.ico Failed to load resource: the server responded with a status of 404 (Not Found)
    worklight.js:5134 response [/MyProject/apps/services/api/MyApp/iphone/init] success: /*-secure-
    {"userPrefs":{},"WL-Authentication-Success":{"wl_directUpdateRealm":{"userId":"null","attributes":{},"isUserAuthenticated":1,"displayName":"null","deviceId":"null"},"wl_remoteDisableRealm":{"userId":"null","attributes":{},"isUserAuthenticated":1,"displayName":"null","deviceId":"null"},"wl_antiXSRFRealm":{"userId":"1n4ulchkhlmjgom2cmafk8qvpm","attributes":{},"isUserAuthenticated":1,"displayName":"1n4ulchkhlmjgom2cmafk8qvpm","deviceId":"1n4ulchkhlmjgom2cmafk8qvpm"},"wl_deviceNoProvisioningRealm":{"userId":"previewDummyId","attributes":{"mobileClientData":"com.worklight.core.auth.ext.MobileClientData@ff55f"},"isUserAuthenticated":1,"displayName":"previewDummyId","deviceId":"previewDummyId"},"wl_anonymousUserRealm":{"userId":"6ba49e22-f899-4b14-ae72-fc4fde9100de","attributes":{},"isUserAuthenticated":1,"displayName":"6ba49e22-f899-4b14-ae72-fc4fde9100de","deviceId":"6ba49e22-f899-4b14-ae72-fc4fde9100de"}},"gadgetProps":{"ENVIRONMENT":"iphone"},"userInfo":{"SubscribeServlet":{"userId":null,"attributes":{},"isUserAuthenticated":0,"displayName":null,"deviceId":null},"wl_directUpdateRealm":{"userId":"null","attributes":{},"isUserAuthenticated":1,"displayName":"null","deviceId":"null"},"wl_authenticityRealm":{"userId":null,"attributes":{},"isUserAuthenticated":0,"displayName":null,"deviceId":null},"SampleAppRealm":{"userId":null,"attributes":{},"isUserAuthenticated":0,"displayName":null,"deviceId":null},"wl_remoteDisableRealm":{"userId":"null","attributes":{},"isUserAuthenticated":1,"displayName":"null","deviceId":"null"},"wl_antiXSRFRealm":{"userId":"1n4ulchkhlmjgom2cmafk8qvpm","attributes":{},"isUserAuthenticated":1,"displayName":"1n4ulchkhlmjgom2cmafk8qvpm","deviceId":"1n4ulchkhlmjgom2cmafk8qvpm"},"wl_deviceAutoProvisioningRealm":{"userId":null,"attributes":{},"isUserAuthenticated":0,"displayName":null,"deviceId":null},"wl_deviceNoProvisioningRealm":{"userId":"previewDummyId","attributes":{"mobileClientData":"com.worklight.core.auth.ext.MobileClientData@ff55f"},"isUserAuthenticated":1,"displayName":"previewDummyId","deviceId":"previewDummyId"},"myserver":{"userId":"6ba49e22-f899-4b14-ae72-fc4fde9100de","attributes":{},"isUserAuthenticated":1,"displayName":"6ba49e22-f899-4b14-ae72-fc4fde9100de","deviceId":"6ba49e22-f899-4b14-ae72-fc4fde9100de"},"wl_anonymousUserRealm":{"userId":"6ba49e22-f899-4b14-ae72-fc4fde9100de","attributes":{},"isUserAuthenticated":1,"displayName":"6ba49e22-f899-4b14-ae72-fc4fde9100de","deviceId":"6ba49e22-f899-4b14-ae72-fc4fde9100de"}}}*/
    worklight.js:5788 No matching configurations found from the server. Defaulting to local configuration
    worklight.js:5134 wlclient connect success
    worklight.js:5134 before: initOptions.onSuccess
    worklight.js:5134 after: initOptions.onSuccess
    worklight.js:5134 wlclient init success
    worklight.js:5134 Request [/MyProject/apps/services/loguploader]
    worklight.js:5134 Application details header: {"applicationDetails":{"platformVersion":"7.0.0.0","nativeVersion":"1161280635"}}WL.Logger.__log @ worklight.js:5134
    worklight.js:5134 Request [/MyProject/apps/services/loguploader]
    worklight.js:5134 Application details header: {"applicationDetails":{"platformVersion":"7.0.0.0","nativeVersion":"1161280635"}}WL.Logger.__log @ worklight.js:5134
    worklight.js:5134 response [/MyProject/apps/services/loguploader] success: 
    worklight.js:5701 Client logs successfully sent to the server
    worklight.js:5134 response [/MyProject/apps/services/loguploader] success: 
    worklight.js:5701 Client logs successfully sent to the server
    worklight.js:5134 Piggybacking event transmission
    worklight.js:5134 Flush called
    worklight.js:5134 Request [/MyProject/apps/services/api/MyApp/iphone/heartbeat]
    worklight.js:5134 Application details header: {"applicationDetails":{"platformVersion":"7.0.0.0","nativeVersion":"1161280635"}}WL.Logger.__log @ worklight.js:5134
    worklight.js:5134 response [/MyProject/apps/services/api/MyApp/iphone/heartbeat] success: 
    worklight.js:5134 Heartbeat sent successfully
    worklight.js:5134 Piggybacking event transmission
    worklight.js:5134 Flush called
    worklight.js:5134 Request [/MyProject/apps/services/api/MyApp/iphone/heartbeat]
    worklight.js:5134 Application details header: {"applicationDetails":{"platformVersion":"7.0.0.0","nativeVersion":"1161280635"}}WL.Logger.__log @ worklight.js:5134
    worklight.js:5134 response [/MyProject/apps/services/api/MyApp/iphone/heartbeat] success: 
    worklight.js:5134 Heartbeat sent successfully
    worklight.js:5134 Piggybacking event transmission
    worklight.js:5134 Flush called
    worklight.js:5134 Request [/MyProject/apps/services/api/MyApp/iphone/heartbeat]
    worklight.js:5134 Application details header: {"applicationDetails":{"platformVersion":"7.0.0.0","nativeVersion":"1161280635"}}WL.Logger.__log @ worklight.js:5134
    worklight.js:5134 response [/MyProject/apps/services/api/MyApp/iphone/heartbeat] success: 
    worklight.js:5134 Heartbeat sent successfully
    worklight.js:5134 Piggybacking event transmission
    worklight.js:5134 Flush called
    worklight.js:5134 Request [/MyProject/apps/services/api/MyApp/iphone/heartbeat]
    worklight.js:5134 Application details header: {"applicationDetails":{"platformVersion":"7.0.0.0","nativeVersion":"1161280635"}}WL.Logger.__log @ worklight.js:5134
    worklight.js:5134 response [/MyProject/apps/services/api/MyApp/iphone/heartbeat] success: 
    worklight.js:5134 Heartbeat sent successfully
    worklight.js:5134 Piggybacking event transmission
    worklight.js:5134 Flush called
    worklight.js:5134 Request [/MyProject/apps/services/api/MyApp/iphone/heartbeat]
    worklight.js:5134 Application details header: {"applicationDetails":{"platformVersion":"7.0.0.0","nativeVersion":"1161280635"}}WL.Logger.__log @ worklight.js:5134
    worklight.js:5134 response [/MyProject/apps/services/api/MyApp/iphone/heartbeat] success: 
    worklight.js:5134 Heartbeat sent successfully
    worklight.js:5134 Piggybacking event transmission
    worklight.js:5134 Flush called
    worklight.js:5134 Request [/MyProject/apps/services/api/MyApp/iphone/heartbeat]
    worklight.js:5134 Application details header: {"applicationDetails":{"platformVersion":"7.0.0.0","nativeVersion":"1161280635"}}WL.Logger.__log @ worklight.js:5134
    worklight.js:5134 response [/MyProject/apps/services/api/MyApp/iphone/heartbeat] success: 
    worklight.js:5134 Heartbeat sent successfully
    worklight.js:5134 Piggybacking event transmission
    worklight.js:5134 Flush called
    worklight.js:5134 Request [/MyProject/apps/services/api/MyApp/iphone/heartbeat]
    worklight.js:5134 Application details header: {"applicationDetails":{"platformVersion":"7.0.0.0","nativeVersion":"1161280635"}}WL.Logger.__log @ worklight.js:5134
    worklight.js:5134 response [/MyProject/apps/services/api/MyApp/iphone/heartbeat] success: 
    worklight.js:5134 Heartbeat sent successfully
    worklight.js:5134 Piggybacking event transmission
    worklight.js:5134 Flush called
    worklight.js:5134 Request [/MyProject/apps/services/api/MyApp/iphone/heartbeat]
    worklight.js:5134 Application details header: {"applicationDetails":{"platformVersion":"7.0.0.0","nativeVersion":"1161280635"}}WL.Logger.__log @ worklight.js:5134
    worklight.js:5134 response [/MyProject/apps/services/api/MyApp/iphone/heartbeat] success: 
    worklight.js:5134 Heartbeat sent successfully
    worklight.js:5134 Piggybacking event transmission
    worklight.js:5134 Flush called
    worklight.js:5134 Request [/MyProject/apps/services/api/MyApp/iphone/heartbeat]
    worklight.js:5134 Application details header: {"applicationDetails":{"platformVersion":"7.0.0.0","nativeVersion":"1161280635"}}WL.Logger.__log @ worklight.js:5134PUBLIC_API.(anonymous function) @ worklight.js:5520window.WLJSX.Ajax.WLRequest.WLJSX.Class.create.createRequestHeaders @ worklight.js:3337window.WLJSX.Ajax.WLRequest.WLJSX.Class.create.sendRequest @ worklight.js:3395window.WLJSX.Ajax.WLRequest.WLJSX.Class.create.initialize @ worklight.js:3309klass @ worklight.js:527sendHeartBeat @ worklight.js:7276onTimerEvent @ worklight.js:896(anonymous function) @ worklight.js:959
    worklight.js:5134 response [/MyProject/apps/services/api/MyApp/iphone/heartbeat] success: 
    worklight.js:5134 Heartbeat sent successfully
    worklight.js:5134 Piggybacking event transmission
    worklight.js:5134 Flush called

I notice there's a date number difference between the files written when I build the project using Eclipse and when I do it from the cli ... is there an easy way to check for and get updates to the CLI?

(Just to be clear, we don't see this problem when using Studio in Eclipse.)

2

There are 2 best solutions below

4
On BEST ANSWER

This is perfectly expected.

From the preview URL it seems you are looking at the "Simple Preview" which actually only loads the web resources - and in this case Cordova is indeed not available, as Cordova is available only when previewing the actual app in either the Mobile Browser Simulator or in the specific environment's IDE (Xcode, Android Emulator, etc...).

If you will launch your app in the Mobile Browser Simulator - this tool provide some Cordova functionality by mimicking it.

If you will take an MBS-preview URL, for exmaple the following - you will not see any errors: http://10.0.0.3:10080/_MobileBrowserSimulator/index.html?webpage=/test/apps/services/preview/test/iphone/1.0/&platform=ios.iphone

However if you'll then "strip" out the MBS and preview the following - you will see the same errors: http://10.0.0.3:10080/test/apps/services/preview/test/iphone/1.0/default/index.html

http://10.0.0.3:10080/test/apps/services/preview/test/iphone/1.0/default/worklight/cordova.js Failed to load resource: the server responded with a status of 404 (Not Found)_mbs_cordova_sim_load_js @ cordova.js:19

2015-06-25 20:01:08.608 cordova.js:24 Uncaught ReferenceError: cordova is not defined

0
On

As Idan explained, this is expected.

I was starting the previews with mfp preview --noshell. If I drop --noshell, it uses the MobileBrowserSimulator link and I don't get these errors.