Getting started with Sesame

Surprisingly easy.

My efforts to set up and try RDF triplestores have been a bit frustrating. I won't go into reasons here, because several of the efforts are on hold for now, but my attempts to set up and use Sesame went so quickly and easily that I wanted to write it up right away.

My main goal with any of the triplestores is to load some RDF that will be stored persistently and then run some SPARQL queries against it. I can do some Java coding if I must, but I wanted to see how far I could get with each triplestore without doing any coding (and especially, no compiling). For bonus points, I wanted to see how much inferencing and OWL usage was possible, but in general I wanted to avoid special features in my initial research because I wanted to establish a baseline. (In an ideal world, OWL support would be part of the baseline!)

Installing and running Sesame

According to the installation instructions, the Sesame server software requires Java 5 or later and "a Java Servlet Container that supports Java Servlet API 2.4 and Java Server Pages (JSP) 2.0, or newer". They "recommend using a recent, stable version of Apache Tomcat".

It was very easy—the kind of "it just works" experience that's a particular pleasure to find in open source software.

I began by downloading and unzipping the zip file of the 2.2.4 Sesame SDK and Apache Tomcat 6.0.18. The instructions in apache-tomcat-6.0.18\RUNNING.txt to get the Tomcat server up and running were simple and straightforward. To install a Sesame server on top of Tomcat, I copied the two war files from openrdf-sesame-2.2.4\war to apache-tomcat-6.0.18\webapps. After I shut down and restarted Tomcat, sending my browser to http://localhost:8080/openrdf-workbench and http://localhost:8080/openrdf-sesame showed welcome screens about how these apps were running with no problem.

Using Sesame

The Workbench is the form-driven interface to Sesame. It let me create repositories, load remote or local data files into them, and then query them all by picking menu choices and filling out forms. It was very easy—the kind of "it just works" experience that's a particular pleasure to find in open source software.

The REST HTTP protocol for doing all these things, which I tested using cURL, was well-documented and easy to to figure out. I After I'd created a "test1" repository using the Workbench, the following cURL command line listed repositories and showed that test1 was one of them (all curl command lines shown here include extra carriage returns for readability):

curl -H "Accept: application/sparql-results+xml, */*;q=0.5" 
  http://localhost:8080/openrdf-sesame/repositories
          

The following loaded some RDF into the test1 repository:

curl -T rdftest2.rdf -H "Content-Type: application/rdf+xml;charset=UTF-8"
  http://localhost:8080/openrdf-sesame/repositories/test1/statements
          

Once the files triples were loaded, the following request sent a URL-encoded version of the SPARQL query "SELECT DISTINCT ?p WHERE {?s ?p ?o}" to the test1 repository:

curl -H "Accept:  application/sparql-results+xml, */*;q=0.5" 
  http://localhost:8080/openrdf-sesame/repositories/test1?query=
  SELECT%20DISTINCT%20%3Fp%20WHERE%20%7B%3Fs%20%3Fp%20%3Fo%7D
          

The server sent back a SPARQL query result format version of the response.

Inferencing

The steps up to this point were all so easy that I decided to push my luck and try some inferencing. I wanted to:

  1. Store someone's home phone number and mobile phone number

  2. Declare that both of these properties were subproperties of phone

  3. Issue a SPARQL query saying "give me any phone numbers for this person"

When you create a Sesame repository, there are nine choices for the type of store ranging from "In Memory Store" to "PostgreSQL RDF Store" and "Remote RDF Store". For my inferencing tests, I picked "Native Java Store RDF Schema", called the repository rdftest1, and uploaded the following file into it:

<rdf:RDF xmlns:o="urn:schemas-microsoft-com:office:outlook#"
  xmlns:f="http://xmlns.com/foaf/0.1/"
  xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">

  <rdf:Description rdf:about="http://localhost:2020/addrbook/RichardMutt">
    <f:firstName>Richard</f:firstName>
    <f:surname>Mutt</f:surname>
    <o:homePhone>463-477-1322</o:homePhone>
    <o:mobilePhone>463-215-8470</o:mobilePhone>
  </rdf:Description>

  <rdf:Property rdf:about="urn:schemas-microsoft-com:office:outlook#homePhone">
    <rdfs:subPropertyOf rdf:resource="http://xmlns.com/foaf/0.1/phone" />
  </rdf:Property>

  <rdf:Property
    rdf:about="urn:schemas-microsoft-com:office:outlook#mobilePhone">
    <rdfs:subPropertyOf rdf:resource="http://xmlns.com/foaf/0.1/phone" />
  </rdf:Property>

</rdf:RDF>
          

Let's say I want to call Richard but can't remember which phone numbers I have for him. The following query asks for the type and number of any phone numbers I have for him, and the little table that follows the query shows what Sesame returned:

PREFIX f:<http://xmlns.com/foaf/0.1/>
PREFIX o:<urn:schemas-microsoft-com:office:outlook#>

SELECT DISTINCT ?phoneType ?phoneNum WHERE { 
  ?s f:phone ?phoneNum; 
  ?phoneType ?phoneNum; 
  f:firstName "Richard";
  f:surname "Mutt".
}
          
phoneType phoneNum
o:homePhone "463-477-1322"
f:phone "463-477-1322"
o:mobilePhone "463-215-8470"
f:phone "463-215-8470"

(The returned data looks much better with the CSS included with openrdf-workbench.war. A "View Source" of the returned data reveals that it's provided in the SPARQL query result format with a processing instruction at the top pointing to an XSLT stylesheet that works with the CSS to display the results nicely in the browser.) The links in the copy of the returned data above lead nowhere, but when you're using it with a running copy of Workbench they let you explore around the data in the repository.

Next

It was particularly cool how many of these steps worked the first or second time I tried them, with no configuration required. I can think of more things I'd like to try with Sesame, but I'm going to keep trying out more triplestores and reporting on the ones that I have much luck with.

14 Comments

On the "really easy to setup a SPARQL endpoint" front, have you taken a look at ARC?


Thanks Bruce, I will add that to my list, but judging from http://arc.semsol.org/docs/v2/getting_started, it looks like I would need some familiarity with PHP first, which I don't have, so this means that I may not get to it for a while.


Many thanks for undertaking this survey, the results are really interesting.

I tried a different task with Sesame the other day, but didn't (yet) win. OK I was tired and maybe missed it in the documentation ... but all I wanted to do was load a SKOS rdf/xml document from disk, and explore it via API or (preferably) SPARQL. Couldn't figure out how.

I wonder whether FOAF+DOAP descriptions of the various SW toolkits could be made available from their providers. Perhaps even with extensions to point out where in their various documents, wikis etc., answers to these common questions can be found.

Also, +1 on reviewing ARC. Assuming you have access to a server with basic PHP facilities, and the username/password for a MySQL db, it should be pretty smooth. ARC is a very impressive package in my experience...


Yeah, I have a problem with PHP as well. But less so than Java ;-)


Sesame is a great tool - and so is ARC. ARC has more power when extracting and presenting information in keeping with it's PHP heritage. Sesame is a very powerful data modelling and storage engine - SAIL being the crown jewels.


It worked for the native store. But, it didn't return any results when I tried it with MySQL or PostGres :(


I tried your installation steps and they were very helpful indeed. I reach this problem though:

I have a working apache tomcat.

I downloaded the .jar i got the openrdf-sesame.war and the openrdf-workbench.war from the /war directory and i copied them to my apache tomcat directory /webapps/

After a while i saw 2 new folders created openrdf-workbench/ and openrdf-sesame/

I hit my servers adress http://localhost:8080/openrdf-sesame/ and I get:

HTTP Status 404 -

type Status report

message

description The requested resource () is not available.
Apache Tomcat/7.0.0

Same with workbench.

Any help would be really appreciated!


I forgot to write it (i think). I restarted my tomcat before i checked the address

Thanks again.


Stratos,

It's been a while since I played with it. openrdf.org seems to be down right now, but Google shows that it has a link to a mailing list which would probably be the best place to ask this.

Bob


Hi Stratos,
I had the same problem (Tomcat 7.0.2 + Sesame 2.3.2). I tried a lot of things but nothing helped. So I decided to install the version as similar as possible to the Bob's settings. On 2nd Sept 2010 it was: Tomcat 6.0.29 + Sesame 2.2.4... and everything went fine - exactly as in this blogs.

michał


I tried installing Sesame 2.3.2 into Tomcat 7.0.2-beta earlier today, and it didn't work - I downgraded Tomcat 7 to 6.0.29 and then it worked for me :)

Sesame 2.3.2 just doesn't seem to work out-of-the-box on the current betas of Tomcat 7


I used Tomcat 6 with the latest version of sesame2 and it worked like a charm. Thank you for the help everyone! :)


Yes, there is some problem with if you deploy sesame 2.3.2 on Tomcat7

The best way to save time is deploy sesame 2.3.2 with Tomcat 6 and every things works as described in this blog

jamshaid


Hi guys,
Did you try with Tomcat 7 the following URL:

http://localhost:8080/openrdf-workbench/