Home > semantic > Setting up Joseki & TDB with a bunch of RDF files

Setting up Joseki & TDB with a bunch of RDF files

November 9, 2009

Here the idea is that you load a directory of RDF statements into a TDB store and front it with Joseki for Sparql querying.

  • Download and expand Joseki and TDB.
  • Copy the tdb jar file to the Joseki llib folder.
  • Add a servlet mapping in web.xml, copying the books example, for your new dataset. eg newDataServiceRef
  • . You’ll use this in your service description for Joseki, below

  • Copy the query.html to one of your own eg mydata.html, and change the form action to point to the url you just set in web.xml
  • I added the following to the joseki-config.ttl

      Prefix

      @prefix sdb:      <http://jena.hpl.hp.com/2007/sdb#> .
      @prefix tdb:     <http://jena.hpl.hp.com/2008/tdb#> .

      TDB Class load

      ## Datasets
       ## Initialize TDB.
       [] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
       tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
       tdb:GraphTDB    rdfs:subClassOf  ja:Model .

      Service

      # Service 3 - SPARQL processor only handling a given dataset
       <#service3>
       rdf:type            joseki:Service ;
       rdfs:label          "My new sparql service" ;
       joseki:serviceRef   "newDataServiceRef" ;   # web.xml must route this name to Joseki
       # dataset part
       joseki:dataset      <#newdata> ;
       # Service part.
       # This processor will not allow either the protocol,
       # nor the query, to specify the dataset.
       joseki:processor    joseki:ProcessorSPARQL_FixedDS ;

      .

      Dataset and Graph

      <#newdata>   rdf:type tdb:DatasetTDB ;
       rdfs:label "A new TDB dataset" ;
       tdb:location "/full/path/to/Data/myJosekiDataDir" ;
       .
       <#graph> rdf:type tdb:GraphTDB ;
       tdb:location "DB" ;
       .
      
  • Start Joseki – make sure Joseki and TDB home are set, wait for the last log message that says the endpoint has started on port 2020
  • export JOSEKIROOT=~/Joseki-3.4.0
    export TDBROOT=~/TDB-0.8.2
  • Load your data in TDB, into your Joseki dataset using tdbload, like this from TDBROOT :
  • bin/tdbloader --loc=/full/path/to/Data/myJosekiDataDir -v /full/path/to/RDFFiles/*.rdf

  • Navigate to your new html page (mydata.html). Try a query – you should get triples back. If you get a message saying “No dataset description for query” then somethings wrong in your joseki-config.ttl.
Advertisements
%d bloggers like this: