1
Vote

oData server with MongoDB on Nodejs with Debian

description

I am trying to run oData server with MongoDB as DB provider, and on my development machine - Windows 8.1 it is working. But when I tried to upload the same code to the Linux - Debian GNU/Linux 7 - production machine it doesn't work.
I got the error Provider fallback failed on the linux machine. MongoDB is locally installed on both machines.
I tried with remote MongoDB on MongoLab but got the same error, although I am connecting to the database (I tried with mongoose and the operation went without errors).

I am using Express 4.

I tried with this code, which works on the Windows:
app.use('/mikrosaray.svc', $data.ODataServer({
            type: contextType,
            CORS: true,
            database: 'salesODB',
            responseLimit: 100,
            basicAuth: function(username, password){
                if (username == 'admin'){
                    return password == 'admin';
                }else return true;
            },
            checkPermission: function(access, user, entitySets, callback){
                if (access & $data.Access.Create){
                    if (user == 'admin') callback.success();
                    else callback.error('Auth failed');
                }else callback.success();
            },
            provider: {
                howto: 'You can pass a customized JayData provider configuration in here.'
            }
        }));
I tried also this on the Linux in the router file:
router.use("/mikrosaray.svc", $data.JayService.OData.Utils.simpleBodyReader());
router.use("/mikrosaray.svc", $data.JayService.createAdapter(Mikrosaray.Context, function (req, res, next) {
    return new Mikrosaray.Context({name: "mongoDB",
                                    databaseName:"salesODB",
                                    address:     "localhost",
                                    port: 27017
                                    });
}));
I am getting the following error in the browser:
Cannot read property 'providerConfiguration' of undefined
TypeError: Cannot read property 'providerConfiguration' of undefined
at JSObjectAdapter.$data.Class.define.processRequest (/home/vgenev/salesODB/node_modules/jaydata/lib/JayService/JSObjectAdapter.js:79:147)
at JSObjectAdapter.$data.Class.define.handleRequest (/home/vgenev/salesODB/node_modules/jaydata/lib/JayService/JSObjectAdapter.js:170:26)
at /home/vgenev/salesODB/node_modules/jaydata/lib/JayService/JayService.js:61:21
at Layer.handle [as handle_request] (/home/vgenev/salesODB/node_modules/express/lib/router/layer.js:82:5)
at trim_prefix (/home/vgenev/salesODB/node_modules/express/lib/router/index.js:302:13)
at /home/vgenev/salesODB/node_modules/express/lib/router/index.js:270:7
at Function.proto.process_params (/home/vgenev/salesODB/node_modules/express/lib/router/index.js:321:12)
at next (/home/vgenev/salesODB/node_modules/express/lib/router/index.js:261:10)
at /home/vgenev/salesODB/node_modules/jaydata/lib/JayService/OData/Helpers.js:144:17
 at Layer.handle [as handle_request] (/home/vgenev/salesODB/node_modules/express/lib/router/layer.js:82:5)
Can someone help me with this issue?
Thank you.

comments