Failed to create virtual graph

Hi I'am trying to create virtual graph by connecting mongoDB from stardog studio.
My MongoDB URI:
mongodb://localhost/dbname After clicking create button I got error

Failed to create virtual graph dbname

I saw log file and it shows error
`ERROR 2019-10-10 11:20:28,587 [stardog-user-1] com.complexible.stardog.virtual.DefaultVirtualGraphRegistry:createVirtualGraph(352): Cannot initialize virtual graph mongoDB
com.complexible.stardog.plan.parser.QueryParseException: Encountered "" at line 1, column 0.
Was expecting one of:
"base" ...
"prefix" ...
"mapping" ...

at com.complexible.stardog.plan.parser.QueryParserImpl.parseDatasourceMappings( ~[stardog-7.0.1.jar:?]
at com.complexible.stardog.virtual.vega.mongo.MongoMappingsParser.parseMappings( ~[stardog-virtual-core-7.0.1.jar:?]
at com.complexible.stardog.virtual.vega.mongo.MongoVirtualGraphFactory.create( ~[stardog-virtual-core-7.0.1.jar:?]
at com.complexible.stardog.virtual.vega.mongo.MongoVirtualGraphFactory.create( ~[stardog-virtual-core-7.0.1.jar:?]
at com.complexible.stardog.virtual.DefaultVirtualGraphRegistry.createVirtualGraph( ~[stardog-virtual-core-7.0.1.jar:?]
at com.complexible.stardog.virtual.DefaultVirtualGraphRegistry.createVirtualGraph( ~[stardog-virtual-core-7.0.1.jar:?]
at com.complexible.stardog.virtual.DefaultVirtualGraphRegistry.add( ~[stardog-virtual-core-7.0.1.jar:?]
at com.complexible.stardog.virtual.SecuredVirtualGraphRegistry.add( ~[stardog-virtual-core-7.0.1.jar:?]
at com.complexible.stardog.protocols.http.server.virtual.admin.VirtualGraphHttpService.addVG( ~[stardog-virtual-protocols-http-server-7.0.1.jar:?]
at com.complexible.stardog.protocols.http.server.virtual.admin.VirtualGraphHttpService.add( ~[stardog-virtual-protocols-http-server-7.0.1.jar:?]
at com.stardog.http.server.undertow.jaxrs.ExtractRoutes.lambda$handleIt$5( ~[stardog-protocols-http-server-7.0.1.jar:?]
at [shiro-core-1.3.0.jar:1.3.0]
at [shiro-core-1.3.0.jar:1.3.0]
at java.util.concurrent.ThreadPoolExecutor.runWorker( [?:1.8.0_222]
at java.util.concurrent.ThreadPoolExecutor$ [?:1.8.0_222]
at [?:1.8.0_222]`

Note:- I have added mongo-java-driver-3.8.2.jar to STARDOG_EXT.

Not sure if i'am missing something!!

Can you share your mapping file?

I should have mentioned I'm completely new to Stardog so i missed the mapping part.Sorry for that.. Just came to know we have to create the mapping file for our data then do a mongodb connection..

  1. I would like to know do I have to create mapping file manually or is there a way stardog studio does it automatically?

  2. If this mapping file I have to create manually can you please share some tutorial or guide as in how can i convert my json data to a mapping file and then make a mongodb connection.

I went through stardog/docs and googled but couldn't find much.

Sorry for being naive.. Just getting started with stardog..

No problem, welcome to Stardog.

Stardog will create a default mapping for relational database targets but I don't believe there is anything similar for json/graphql mappings so you'll need to create a mapping by hand.

There is this blog post Native MongoDB Support is Here! | Stardog
and the documentation that you said you looked at already Home | Stardog Documentation 7.8.0

I'd take a look over it again and see what you can make of it and check back here if you get stuck or need help.

We all have to start somewhere. Feel free to ask questions.

Thanks for the quick response.. I will try it out and get back.

Hi @zachary.whitley

As per our last discussion I went through few docs and webinar videos on virtual graph and tried to create simple mapping file for my sample mongodb collection..

Steps I followed:-

  1. I created a movie.sms file in which i wrote my mapping for my sample data, as follows

"_id": "?movieId",
"title": "?name",
"year": "?year",
"genres": [ "?genre" ]
TO {
?movie a :Movie;
:title ?name;
:year ?year;
:cast ?cast;
:genre ?genre .
BIND (template("{movieId}") AS ?movie)
BIND (xsd:date(?year) AS ?year)

  1. After this i clicked create virtual graph which created a file under virtual graph tab with name given as "movies".

  2. Now i press save changes button i got an error "failed to create virtual graph".Error this time is different than the last one.. I checked my log and it says

java.lang.StackOverflowError: null ERROR 2019-10-12 17:48:13,031 [stardog-user-8] com.stardog.http.server.undertow.ErrorHandling:writeError(138): Unexpected error on the server** java.lang.StackOverflowError: null at java.util.ArrayList$ArrayListSpliterator.estimateSize( ~[?:1.8.0_222] at java.util.Spliterator.getExactSizeIfKnown( ~[?:1.8.0_222] at ~[?:1.8.0_222] at ~[?:1.8.0_222] at$ReduceOp.evaluateSequential( ~[?:1.8.0_222] at ~[?:1.8.0_222] at ~[?:1.8.0_222] at com.complexible.stardog.virtual.vega.json.JsonMappingArrayGrouping.getArrays( ~[stardog-virtual-core-7.0.1.jar:?] at com.complexible.stardog.virtual.vega.json.JsonMappingArrayGrouping.lambda$getArrays$3( ~[stardog-virtual-core-7.0.1.jar:?] at$7$1.accept( ~[?:1.8.0_222] at java.util.ArrayList$ArrayListSpliterator.forEachRemaining( ~[?:1.8.0_222] at ~[?:1.8.0_222]

Not sure if this is because i was not able to create mapping file properly or is it something else?
Need support.

Have uploaded my sample json data file which is present on mongodb.

movies.json (809 Bytes)

Congratulations, I think you may have your first bug report. :slight_smile:

What version of Stardog are you running?

Stardog version is 7.0.1

This may or may not fix your issue, but it looks like :cast ?cast; in your TO clause should be :cast ?actors;.

1 Like

Thanks @jason for pointing it out.. I changed it but still i got the same error.. I am attaching the log file.. stardog.log (97.6 KB) Please have a look

@zachary.whitley @jason

I have few doubts apart from above mentioned error, just to make sure I have not missed anything.
I saw in docs for RDBMS virtual graph we have to give jdbc properties like
jdbc.url=jdbc:mysql://localhost/music jdbc.username=admin jdbc.password=admin jdbc.driver=com.mysql.jdbc.Driver
I was wondering if such kind of properties are not required for mongodb as in Stardog studio i see option only for mongodb.uri !!

One more thing i want to clarify is, I saw a command in docs to add a new virtual graph
stardog-admin virtual add dept.ttl

Is it required to add virtual graph through terminal(using above command) even if we are using Stardog Studio to create the graph??

@zachary.whitley @jason

This BIND expression is your issue. You cannot use the same variable in both the source and target. You should use a different target variable, eg BIND(xsd:date(?year) as ?yearDate), and use that in the mapping. That said, if it's just a year, it cannot be cast to a date.

Regarding the properties file, you can include the MongoDB username and password in the URI. There's an example in the docs.

When creating a virtual graph in Stardog Studio, it is not required to do anything additional from the command line.


1 Like

I forgot to mention that it's possible to do the cast in the target of the mapping like so:

    :boxOffice "?boxOffice"^^xsd:integer ;

Thanks alot @jess and team after doing this change it worked :slight_smile: i am able to create the graph, it shows me a success message.

Regarding mongodb connection I have done as suggested in docs


Note:- My mongodb and stardog are running on a remote server where as my studio is running on a local machine (local machine and remote server are connected via VPN) . Stardog Studio is connected to the server.

After this i ran a simple query of SELECT.. But i see empty result with a message successfully executed query.. How can i be sure my stardog studio is connected to mongodb. When i execute a query I checked stardog logs also but nothing gets printed there.

It would be great if you can help resolve this

Can you share the query that is not returning any results? What is the name of your virtual graph?

It worked @jess may there was some network issue.. Thanks a lot stardog team for the support..

There was a bug causing your initial error that prevented you from establishing the connection and then creating the mapping in Studio to fully create the Virtual Graph. We'll have a fix for that out soon. But for all other data sources (and for Mongo shortly), Jess is right - you can create them fully from within Studio.