IBM Worklight 6.1 - Uncaught ReferenceErrors: WLJQ

2019-05-10 08:31发布

I'm using IBM Worklight Developer Edition 6.1 installed in Eclipse Juno as my IDE and backbonejs as my main javascript framework for my project.

My index.html

<!doctype html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
    <script>window.$ = window.jQuery = WLJQ;</script>

    <script data-main="js/main" src="js/libs/require/require.js"></script>
</head>
<body>

</body>
</html>

My main.js

require.config({
    paths: {
        jquery: 'libs/jquery/jquery-min',
        underscore: 'libs/underscore/underscore-min',
        backbone: 'libs/backbone/backbone-min',
        templates: '../templates',
        bootstrap: 'bootstrap.min',
        initOptions: 'initOptions',
        biiRibMobile: 'biiRibMobile',
        messages: 'messages'
    },
});
require(['app', ], function(App) {
    App.initialize();
});

My app.js

// Filename: app.js
define(['jquery', 'underscore', 'backbone', 'router', // Request router.js
'bootstrap', 'initOptions', 'biiRibMobile', 'messages', ], function($, _, Backbone, Router, bootstrap, initOptions, biiRibMobile, messages) {
    var initialize = function() {
            // Pass in our Router module and call it's initialize function
            Router.initialize();
        };
    return {
        initialize: initialize
    };
});

My initOptions.js

var wlInitOptions = {

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

    analytics : {
        enabled: false
        //url : ''
    }

};

if (window.addEventListener) {
    window.addEventListener('load', function() { WL.Client.init(wlInitOptions); }, false);
} else if (window.attachEvent) {
    window.attachEvent('onload',  function() { WL.Client.init(wlInitOptions); });
}

Thanks a lot in advance.

7条回答
孤傲高冷的网名
2楼-- · 2019-05-10 08:40

@DavidDhuyveter has a good answer in the comments. I had this problem on a Mac and on a Windows PC. His answer fixed my Mac issues.

For Windows, the temp folder should be in /Users/you/AppData/Local/Temp/1/ or something along those lines.

EDIT David comments were deleted. This is the original:

If you are on a mac, do the following: Exit eclipse. Open a terminal window and cd $TMPDIR, rm -rf wlBuildResources wlPreview, Restart Eclipse, rebuild your app and you should be good to go –

查看更多
Deceive 欺骗
3楼-- · 2019-05-10 08:41

same problem with WL 6.1.My app did not work with the link "preview as common ressources", but it worked with the mobile browser simulator

I Solved it by exiting eclipse then deleted wlbuildressources and wlpreview folder in tmp folder (/tmp on linux). After that, I restarted eclipse and it worked. However, it is a bug in 6.1.

查看更多
手持菜刀,她持情操
4楼-- · 2019-05-10 08:46

This problem actually happens a lot and it is actually really frustrating. Sometimes everything will be working for awhile and out of nowhere, this lovely error pops up. Something you can do instead (which has worked for me consistently) is:

  1. In Eclipse, go to Project -> Clean ...
  2. Select clean selected project checkbox, and select your Project
  3. Hit ok

I would try that first and see what it does. If not, you can do the trusted method of removing and re-importing.

查看更多
三岁会撩人
5楼-- · 2019-05-10 08:50

I think I finally figured out an easy workaround for this one.

Right click on your project name in Eclipse, choose Close Project and then right-click again and choose Open Project. This fixed my broken preview pages.

查看更多
小情绪 Triste *
6楼-- · 2019-05-10 08:52

What helps me each time when I run into this problem while opening the app from the Worklight console is that I right-click on the app, choose Run As -> Preview before I attempt to load it from the Worklight console. After that, app starts working no matter from where I launch it.

查看更多
不美不萌又怎样
7楼-- · 2019-05-10 08:58

The quickest workaround for me is to remove the project and then add the project into the workspace again. This need not suffer from renaming the project or other process.

查看更多
登录 后发表回答