mount is failing for foxx application

124 views
Skip to first unread message

Vikas Tandi

unread,
Nov 22, 2014, 11:18:06 PM11/22/14
to aran...@googlegroups.com
Hi,

I have created a foxx-application for a app I am working on. I was trying to install the foxx app in arangodb mainline.
I have followed the following steps:
1) create new database from arangosh 'db._createDatabase("databasename")'
2) run command 'foxx-manager --server.database "<database-name>" fetch directory <source-path> <version>'
3) then run command 'foxx-manager --server.database "<database-name>" mount <appid> <mount-path>'

But, when I looked at the logs it is giving following error

2014-11-23T04:08:44Z [2584] ERROR Cannot compute Foxx application routes: [ArangoError 1924: graph not found]
2014-11-23T04:08:44Z [2584] ERROR Cannot mount Foxx application 'app:contactspace:1.0': Error: Cannot compute the routing table for Foxx application 'app:contactspace:1.0', check the log file for errors!\n  at Object.exports.appRoutes (/usr/share/arangodb/js/server/modules/org/arangodb/foxx/manager.js:1525:15)\n  at Object.reloadRouting (/usr/share/arangodb/js/server/modules/org/arangodb/actions.js:1241:38)\n  at global context method:1:33\n

I am not able understand the cause of this error. The setup script is running fine after mount but the mount itself is giving error.

Thanks,
Vikas Tandi

Lucas Dohmen

unread,
Nov 24, 2014, 3:03:57 AM11/24/14
to aran...@googlegroups.com
Hello Vikas,

Can you share more details about your Foxx App? Does it do something with graphs? To my knowledge, the foxx manager doesn’t do anything with graphs per default.

Best Wishes
Lucas

--
You received this message because you are subscribed to the Google Groups "ArangoDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to arangodb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jan

unread,
Nov 24, 2014, 7:48:05 AM11/24/14
to aran...@googlegroups.com
I guess the error is due to the application code doing something with graphs.
When the application is mounted, the application controllers will be loaded. If the controllers contain some code outside the routes, this code will also be executed.
If this code tries to access a non-existing graph and throw an error, then mounting the application will fail.

Example:

(function () {
  var graphs = require("org/arangodb/general-graph");
  var graph = graphs._graph("mygraph");

  controller.get("/myroute", function (req, res) {
    graph.doSomething();
  });

)();

In the above code, the code for route /myroute will not be executed during mounting, but the few lines above it will be.
If that code involves graph access, it might raise an error if the graph does not exist etc.

So please check your application controllers' code for actions involving graphs.

Lucas Dohmen

unread,
Nov 24, 2014, 8:31:07 AM11/24/14
to aran...@googlegroups.com
Hi,

If that is the problem, the solution would be to put the creation of the graph into your setup.js file :)

Best Wishes
Lucas

Vikas Tandi

unread,
Nov 24, 2014, 8:35:46 PM11/24/14
to aran...@googlegroups.com
Hi Lucas,

Yes I am creating a general graph with only one edge definition. below is the setup.js for that

// load modules
    var graph_module = require("org/arangodb/general-graph");
    
    // create graph if does not already exists
    var graph = null;
    if(!graph_module._exists("sampleGraph")) {
        var containsXRelation = graph_module._directedRelation("containsX", ["X"], ["X"]);
        var edgeDefinitions = graph_module._edgeDefinitions(containsXRelation);
        graph = graph_module._create("sampleGraph", edgeDefinitions);
    }
    else {
        graph = graph_module._graph("sampleGraph");
    }
them some more stuff like creating index's ...

Also, I have some graph related code outside the controller actions

 var sampleGraph = graph_module._graph("sampleGraph");
 var vertex = contactSpaceGraph._getVertexCollectionByName("contactX");
 var edge = contactSpaceGraph._getEdgeCollectionByName("X");

I did this outside of the actions because I do not want to create them again and again. should I move them inside of every controller actions.

Thanks,
Vikas

Lucas Dohmen

unread,
Nov 25, 2014, 4:38:44 AM11/25/14
to aran...@googlegroups.com
Hi Vikas,

What you’re doing is what I would have done as well, there are a few little errors in there that lead to the errors:

* You wrote contactX instead of containsX in the controller
* You switched the name of the vertex collection and the edge collection in your controller (getVertexCollectionByName should receive X, getEdgeCollectionByName should receive containsX)

If you change those things, you are good to go :) Just tried it locally.

A small remark:
In Foxx the idea is that every collection name is prefixed with some information about the mount point. The reason for that is that you should be able to install a Foxx app multiple times without them having a conflict – also multiple apps might have a collection ‘x’ and expect different things to be stored in there. This is why we have applicationContext.collectionName :) I would suggest to use this when you name your graph-related collections as well! If you want to see how it works, I converted your snippets into a simple example app. Here’s the Gist for it:


Best Wishes
Lucas

Vikas Tandi

unread,
Nov 25, 2014, 8:19:01 PM11/25/14
to aran...@googlegroups.com
Hi Lucas,

Thanks a lot for for your help. I have updated my app according to the example app provided by you and tested the app on arangodb dev instance locally. It worked fine.
But, it was still giving the same error at mount step when I tried to integrate in mainline. Then I moved all graph related statements inside the action and it solved the problem.
I have changed the graph.js in following way

var relationName = applicationContext.collectionName("containsX");
var vertexCollectionName = applicationContext.collectionName("X");
var graph_module = require("org/arangodb/general-graph");
var Foxx = require("org/arangodb/foxx");
 
var controller = new Foxx.Controller(applicationContext);
 
controller.get('/vars', function (req, res) {
var sampleGraph = graph_module._graph("sampleGraph");
var vertex = contactSpaceGraph._getVertexCollectionByName(vertexCollectionName);
var edge = contactSpaceGraph._getEdgeCollectionByName(relationName);
// my code
....
....

res.json({
vertex: vertexCollectionName,
relation: relationName
});
});

But only problem here is that I have to duplicate these statements
var sampleGraph = graph_module._graph("sampleGraph");
var vertex = contactSpaceGraph._getVertexCollectionByName(vertexCollectionName);
var edge = contactSpaceGraph._getEdgeCollectionByName(relationName);

for every action in my controller.

Anyways, thanks for your help

Thanks,
Vikas

--
You received this message because you are subscribed to a topic in the Google Groups "ArangoDB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/arangodb/ul9WMEAcPqM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to arangodb+u...@googlegroups.com.
328.png

Lucas Dohmen

unread,
Nov 26, 2014, 8:23:10 AM11/26/14
to aran...@googlegroups.com
Hi Vikas,

You’re welcome :) Did you do only do the `mount` step and didn’t use `install`? Because install is the combination of first executing the setup script and then mounting it. If you only mount the app, your setup will not be executed which leads to errors you described.

Best Wishes
Lucas

Anyways, thanks for your help <328.png>

Thanks,
Vikas

Vikas Tandi

unread,
Nov 29, 2014, 10:04:39 PM11/29/14
to aran...@googlegroups.com
Hi Lucas,

I am explicitly calling foxx-manager setup. So, I am not facing the errors you are talking about.
Thanks again for your help.

- Vikas

Lucas Dohmen

unread,
Dec 1, 2014, 3:44:56 AM12/1/14
to aran...@googlegroups.com
Hi Vikas,

Ok, that’s weird! Have you tried to install the Gist I posted as a Foxx app?

Best Wishes
Lucas

Vikas Tandi

unread,
Dec 1, 2014, 8:41:42 AM12/1/14
to aran...@googlegroups.com
Hi Lucas,

Yes I have updated my code according to the sample app you have posted. Then I tested the app by running the dev instace of arangodb.

After that I have installed the app in prod by running following commands:

Fetched the foxx app in local repository
foxx-manager --server.database "ContactSpaceDB" directory /home/contactspaceadmin/arangodb/source/contactspaceplus/databases/ContactSpaceDB/contactspace/ 1.0

Then checked whether foxx app is fetched properly by running command
foxx-manager --server.database "ContactSpaceDB" fetched

Name            Author         Description                                   AppID                   Version    Path
-------------   ------------   -------------------------------------------   ---------------------   --------   -----------------
contactspace    vikas tandi    foxx app to manage contacts of phone users    app:contactspace:1.0    1.0        contactspace-1.0
-------------   ------------   -------------------------------------------   ---------------------   --------   -----------------

then mounted the application
foxx-manager --server.database "ContactSpaceDB" mount app:contactspace:1.0 /contactspace

then run the setup script
foxx-manager --server.database "ContactSpaceDB" setup /contactspace

Then hit the url
DNS-NAME:8529/_db/ContactSpaceDB/contactspace/<action-name>

Am I missing something here. According, to the documentation install does the same thing.

Thanks,
Vikas Tandi

Lucas Dohmen

unread,
Dec 5, 2014, 7:33:46 AM12/5/14
to aran...@googlegroups.com
Hi,

That's correct. Just to understand this entirely: When you change your app by inlining those statements into the controller actions, you don't have these problems, right? This only happens in production mode when you don't inline?

Best Wishes
Lucas

Vikas Tandi

unread,
Dec 5, 2014, 10:03:34 AM12/5/14
to aran...@googlegroups.com
Hi Lucas,

How's you foot now. Hope you are feeling better now.

Let me write down all the facts
- This issue happens only in production environment.
- These statements were creating problem:
 var contactSpaceGraph = graph_module._graph("contactSpaceGraph");
 var contactCardVertex = contactSpaceGraph._getVertexCollectionByName(vertexCollectionName);
var containsContactEdge = contactSpaceGraph._getEdgeCollectionByName(edgeName);

- When I put these statements in global scope the mount was failing.
- When I moved these statements inside the action the issue was resolved.

I hope it's clear now.

Thanks,
Vikas 

Lucas Dohmen

unread,
Dec 9, 2014, 5:48:56 AM12/9/14
to aran...@googlegroups.com
Hi Vikas,

My foot is well again, thank you :) Thanks for the clarification :) Does [this gist](https://gist.github.com/moonglum/828053de241ad7126b73) properly reproduce the behaviour you are seeing?

Best Wishes
Lucas
signature.asc

Frank Celler

unread,
Dec 29, 2014, 3:58:46 AM12/29/14
to aran...@googlegroups.com
Hi Vikas,

has tzhis issue been solved?

regards
  Frank
To unsubscribe from this group and all its topics, send an email to arangodb+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages