Connecting to a sparql endpoint

Dec 3, 2013 at 9:51 AM
I'm trying to connect to a sparql endpoint that I know it works.
I downloaded db v 1.5, opened nerd dinner sample (by default has connection type http so it gives error), i changed connection string to:
<add key="BrightstarDB.ConnectionString" value="type=dotnetrdf;configuration=c:\Program Files\BrightstarDB\dotNetRdf.config.ttl;query=;update=;" />
I created .ttl file
@prefix dnr: <>.
@prefix : <>.

:sparqlQuery a dnr:SparqlQueryEndpoint ;
    dnr:type "VDS.RDF.Query.SparqlRemoteEndpoint" ;
    dnr:queryEndpointUri <> .

:sparqlUpdate a dnr:SparqlUpdateEndpoint ;
    dnr:type "VDS.RDF.Update.SparqlRemoteUpdateEndpoint" ;
    dnr:updateEndpointUri <> .
but when i try to run the sample i get
[BrightstarClientException: Could not create a SPARQL Query processor from the configured Query property.]
   BrightstarDB.Client.DotNetRdfDataObjectContext..ctor(ConnectionString connectionString) +1483
   BrightstarDB.EntityFramework.BrightstarEntityContext.OpenStore(ConnectionString connectionString, Nullable`1 enableOptimisticLocking, String updateGraphUri, IEnumerable`1 datasetGraphUris, String versionGraphUri) +202
   BrightstarDB.EntityFramework.BrightstarEntityContext..ctor(EntityMappingStore mappings, String updateGraphUri, IEnumerable`1 datasetGraphUris, String versionGraphUri) +149
   BrightstarDB.Samples.NerdDinner.Models.NerdDinnerContext..ctor() in c:\Program Files\BrightstarDB\Samples\Server\NerdDinner\BrightstarDB.Samples.NerdDinner\Models\NerdDinnerContext.cs:61
   BrightstarDB.Samples.NerdDinner.Controllers.HomeController..ctor() in c:\Program Files\BrightstarDB\Samples\Server\NerdDinner\BrightstarDB.Samples.NerdDinner\Controllers\HomeController.cs:13
I know the config file is found because i get error otherwise.
The error is the same regardless of actual endpoint value in url. Any idea what the pb is?

Also, in documentation "other stores/Example Configurations" the first 2 lines(for prefix) need to end with a "." (dot); using your sample gives parsing error.
Dec 3, 2013 at 11:15 AM

I'm not at my development machine right now so I'm not able to delve into the code. But can you tell me if the error message give you any inner exception detail ?

I'll log bugs on the doc typos and the sample (it should have been updated to type=rest when I did the 1.5 release).


Dec 3, 2013 at 12:16 PM
Nope, inner exception is null.
Dec 3, 2013 at 12:32 PM
OK - I'll have to try tracing it through, and while I'm there I can make it include an inner exception value when it throws!
Dec 3, 2013 at 8:14 PM
I found the problem and fixed it. The source is now in the GitHub repository if you want to build from source, or else it will go into the 1.5.1 patch.

The problem was that the code was expecting an ISparqlQueryProcessor instance, not a SparqlRemoteEndpoint, and an ISparqlUpdateProcessor instance, not a SparqlRemoteUpdateEndpoint. I've added some code in now so that it will automatically wrap SparqlRemoteEndpoint and SparqlRemoteUpdateEndpoint.

I think that there is a possible workaround with 1.5 which is to add configuration to create a RemoteQueryProcessor wrapper around the SparqlRemoteEndpoint and a RemoteUpdateProcessor wrapper around the SparqlRemoteUpdateEndpoint - you can do all of this in the DotNetRDF configuration file (see Having said that, I couldn't see in the documentation an example of wrapping the update endpoint...but if it works the configuration should be pretty easy to work out from the RemoteQueryProcessor example.


Dec 4, 2013 at 8:10 AM
Changing from config gets me into other errors, so i took the source code, compiled it, the app load with empty table and I try to insert a new record.
Now i have other errors:

SparqlUpdatableStore/ExecuteQuery: "var query = parser.ParseFromString(queryExpression);"

crashes with "Cannot use an Empty URI to refer to the document Base URI since there is no in-scope Base URI!"
because of the expression it receives:
SELECT ?p ?o ?g FROM NAMED <> FROM NAMED <> WHERE { GRAPH ?g { <> ?p ?o } }
it has 2 "FROM NAMED" empty clauses.

   at VDS.RDF.Tools.ResolveUri(String uriref, String baseUri)
   at VDS.RDF.Parsing.SparqlQueryParser.TryParseFrom(SparqlQueryParserContext context)
   at VDS.RDF.Parsing.SparqlQueryParser.ParseInternal(SparqlQueryParserContext context)
   at VDS.RDF.Parsing.SparqlQueryParser.ParseInternal(TextReader input)
   at VDS.RDF.Parsing.SparqlQueryParser.ParseFromString(String queryString)
   at BrightstarDB.Client.SparqlUpdatableStore.ExecuteQuery(String queryExpression, IList`1 datasetGraphUris) in d:\temp\0\BrightstarDB-develop\src\core\BrightstarDB\Client\SparqlUpdatableStore.cs:line 29
   at BrightstarDB.Client.RemoteDataObjectStore.<GetTriplesForDataObject>d__6.MoveNext() in d:\temp\0\BrightstarDB-develop\src\core\BrightstarDB\Client\RemoteDataObjectStore.cs:line 148
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at BrightstarDB.Client.DataObject.BindTriples(IEnumerable`1 triples) in d:\temp\0\BrightstarDB-develop\src\core\BrightstarDB\Client\DataObject.cs:line 727
   at BrightstarDB.Client.RemoteDataObjectStore.BindDataObject(DataObject dataObject) in d:\temp\0\BrightstarDB-develop\src\core\BrightstarDB\Client\RemoteDataObjectStore.cs:line 143
   at BrightstarDB.Client.DataObject.CheckLoaded() in d:\temp\0\BrightstarDB-develop\src\core\BrightstarDB\Client\DataObject.cs:line 736
   at BrightstarDB.Client.DataObject.AddDataObjectProperty(IDataObject type, IDataObject value) in d:\temp\0\BrightstarDB-develop\src\core\BrightstarDB\Client\DataObject.cs:line 570
   at BrightstarDB.Client.DataObject.AddProperty(IDataObject type, Object value, String lang) in d:\temp\0\BrightstarDB-develop\src\core\BrightstarDB\Client\DataObject.cs:line 197
   at BrightstarDB.EntityFramework.BrightstarEntityObject.Attach(EntityContext context) in d:\temp\0\BrightstarDB-develop\src\core\BrightstarDB\EntityFramework\BrightstarEntityObject.cs:line 790
   at BrightstarDB.EntityFramework.BrightstarEntitySet`1.Add(T item, String resourceAddress) in d:\temp\0\BrightstarDB-develop\src\core\BrightstarDB\EntityFramework\BrightstarEntitySet.cs:line 99
   at BrightstarDB.EntityFramework.BrightstarEntitySet`1.Add(T item) in d:\temp\0\BrightstarDB-develop\src\core\BrightstarDB\EntityFramework\BrightstarEntitySet.cs:line 59
   at BrightstarDB.Samples.NerdDinner.Controllers.HomeController.Create(Dinner dinner) in d:\temp\0\BrightstarDB-develop\samples\Samples\Server\NerdDinner\BrightstarDB.Samples.NerdDinner\Controllers\HomeController.cs:line 49
Dec 7, 2013 at 12:41 PM
Apologies for the delay in looking at this...real life got in the way :)

I think I tracked down the problem to the assumption in the SparqlDataObjectStore that an update graph URI and version graph URI are provided. I've changed the code now so that if those graphs are not defined in the connection string, then the FROM NAMED <> clauses are not added to the graph. The change is available from the develop branch on github.

I created a basic unit test that showed the error and it now passes when connecting to the DotNetRDF in-memory triple store. If you can try it out with whatever triple store you are connecting to and let me know if it works that would be great.


Dec 10, 2013 at 10:53 AM
Seems to work fine now,