ArangoError 3103: failed to invoke module

118 views
Skip to first unread message

Gareth Cox

unread,
Sep 7, 2015, 7:33:22 AM9/7/15
to ArangoDB
Hi All

I'm trying to add a model to my Foxx App, namely 'PropertyTypes'.
I've created propertytype.js with a simple schema.
I've created a simple PropertyTypes.js in repositories.
I'm now trying to get the controllers working, but running into a weird problem.
(Also, I think the code may be wrong, but its copy/paste from my other app which works).
The collection does exist.
ArangoDB 2.6.2 on Mac OS X.
Controllers code bellow results in:
ArangoError 3103: failed to invoke module

'use strict';
var _ = require('underscore');
var joi = require('joi');
var Foxx = require('org/arangodb/foxx');
var ArangoError = require('org/arangodb').ArangoError;
var PropertyTypes = require('repositories/propertytypes');
var PropertyType = require('models/propertytype');
var controller = new Foxx.Controller(applicationContext);
var db = require('org/arangodb').db;

var PropertyTypeIdSchema = joi.string().required()
.description('The id of the Property Type')
.meta({allowMultiple: false});

/**
* Something wrong here
* Deleting the code below allows the Foxx app to work.
* Also, looks weird, PropertyTypes = new PropertyTypes???
**/

var PropertyTypes = new PropertyTypes(
  applicationContext
.collection('PropertyTypes'),
 
{model: PropertyType}
);

/** Creates a new item.
 *
 * Creates a Property Type
 */

controller
.post('/', function (req, res) {
       
var aType = req.parameters.PropertyType;
       
var newType = PropertyTypes.createOrSavePropertyType( aType.forClient() );
        res
.json(newType);
})
.bodyParam('PropertyType', {
  description
: 'The Property Type you want to create',
  type
: PropertyType
})
.errorResponse(ArangoError, 404, 'The PropertyType could not be created');

/** Lists of all Attribute Types.
 *
 * This function simply returns the list of all Property Types.
 */

controller
.get('/', function (req, res) {
  res
.json(_.map(PropertyTypes.all(), function (model) {
   
return model.forClient();
 
}));
});


Jan

unread,
Sep 7, 2015, 7:58:45 AM9/7/15
to ArangoDB
Hi,

"failed to invoke module" is normally thrown when a `require()` operation fails for whatever reason.
Can you try setting to application to dev mode in the web interface? That may bring up a stack trace when accessing a URL of the application.
Apart from that, the following part of the code looks suspicious, because you're redefining variable `PropertyTypes`:


var PropertyTypes = new PropertyTypes(
  applicationContext
.collection('PropertyTypes'),
 
{model: PropertyType}
);

Can yon try renaming the assigned variable to some other name, e.g. `propertyTypes` (with lower-case).
Furthermore, the assigned variable `PropertyTypes` is not used in the above controller code, so it may be even better to delete that section of code.

Finally, I think error reporting for Foxx apps has been somewhat improved in later versions of ArangoDB, so using 2.6.7 may provide better diagnostic information in development mode.

Best regards
Jan

Gareth Cox

unread,
Sep 7, 2015, 8:08:30 AM9/7/15
to ArangoDB
Hi Jan

That suspicious code is automatically generated when I create a new Foxx application.
Perhaps we should look at the code generator when creating a new Foxx app?
In the mean time I will change it.
As for the full stack:

[ArangoError 3103: failed to invoke module
File: /usr/local/var/lib/arangodb-apps/_db/EVADB/eva/APP/controllers/PropertyTypes.js]
  at
[object Object].Module.run (/usr/local/Cellar/arangodb/2.6.2/share/arangodb/js/common/bootstrap/modules.js:1420:20)
  at
ArangoApp.loadAppScript (/usr/local/Cellar/arangodb/2.6.2/share/arangodb/js/server/modules/org/arangodb/foxx/arangoApp.js:452:24)
  at mountController
(/usr/local/Cellar/arangodb/2.6.2/share/arangodb/js/server/modules/org/arangodb/foxx/routing.js:661:7)
  at
/usr/local/Cellar/arangodb/2.6.2/share/arangodb/js/server/modules/org/arangodb/foxx/routing.js:630:9
  at
Array.forEach (native)
  at routeApp
(/usr/local/Cellar/arangodb/2.6.2/share/arangodb/js/server/modules/org/arangodb/foxx/routing.js:629:32)
  at
Object.routes (/usr/local/Cellar/arangodb/2.6.2/share/arangodb/js/server/modules/org/arangodb/foxx/manager.js:268:10)
  at foxxRouting
(/usr/local/Cellar/arangodb/2.6.2/share/arangodb/js/server/modules/org/arangodb/actions.js:1054:74)
  at execute
(/usr/local/Cellar/arangodb/2.6.2/share/arangodb/js/server/modules/org/arangodb/actions.js:1308:7)
  at
Object.routeRequest (/usr/local/Cellar/arangodb/2.6.2/share/arangodb/js/server/modules/org/arangodb/actions.js:1329:3)
  at
Function.actions.defineHttp.callback (/usr/local/Cellar/arangodb/2.6.2/share/arangodb/js/actions/api-system.js:58:15)

Jan

unread,
Sep 7, 2015, 8:12:44 AM9/7/15
to ArangoDB
Hi Gareth,

I see. I remember there was some issue having to do with the Foxx code generator, and I think was fixed in an ArangoDB version later than 2.6.2.
Maybe it's worth updating to 2.6.7 then.

Best regards
Jan
...

Gareth Cox

unread,
Sep 7, 2015, 8:18:03 AM9/7/15
to ArangoDB
Thanks Jan

I'm upgrading as we speak.
I will get back to you should my problem persist.

Regards
Dusty

Gareth Cox

unread,
Sep 7, 2015, 8:33:50 AM9/7/15
to ArangoDB
Hi again Jan

I did the upgrade and you're correct. The error report was far more helpful, object is not a function and then syntax error in another file.
All fixed up and working!
Keep up the awesome work and thanks!

Kind Regards

Dusty

On Monday, 7 September 2015 14:12:44 UTC+2, Jan wrote:
Reply all
Reply to author
Forward
0 new messages