Running Joseki from within Jetty

July 06, 2011 – tagged SPARQL, Howto, Ubuntu

Flattr this


I wanted to set up Joseki, a SPARQL endpoint written in Java, on our database server. Joseki can run standalone (with a script that comes bundled in the distribution) or in a web application server, such as Jetty. As we are already running a Jetty instance for our Apache Solr search engine, it makes a lot of sense to also use that one for the Joseki server. In this text, I'm describing what needs to be done in order to get Joseki running withing Jetty.


We're running Ubuntu Server, i.e. I'll assume Jetty was already installed via apt-get install jetty. In that case, Jetty has its configuration base in /etc, but the web applications live in /var/lib/jetty/webapps/. By default, the latter folder contains only a README.TXT and a root folder for the default welcome page, in my case there's also a symlink to the Solr folder.

Putting the Joseki files in the right place

Basically, it seems pretty easy:

  • download and unzip Joseki (to Joseki-3.4.4, say)
  • copy all jar files from the lib/ subfolder to /usr/share/jetty/lib/ext/ (this folder is on Jetty's class path by default) and set rights appropriately, if necessary
  • copy the webapps/joseki subfolder to /var/lib/jetty/webapps and set rights appropriately, if necessary

Now, if you (re)start Jetty (don't forget to edit /etc/default/jetty and to set NO_START=0), you can already see Joseki's default page at http://localhost:8080/joseki/.

Tell Jetty where to find the Joseki configuration

However, we still need to adapt the configuration file web.xml in the WEB-INF/ folder to our environment, that is:

  • change <param-value>joseki-config.ttl</param-value> to <param-value>/WEB-INF/joseki-config.ttl</param-value> throughout the file
  • put the correct joseki-config.ttl file in the WEB-INF/ folder

Tell Joseki where to store the data

In our case, we use TDB as a backend, i.e. we base our joseki-config.ttl on the default joseki-config-tdb.ttl from the Joseki distribution. This file is an RDF description of the services that should be provided. One entry is of the form

<#dataset> rdf:type      tdb:DatasetTDB ;
    tdb:location "TDB" ;

where "TDB" is the path where the TDB data should live. This should be changed to an absolute path, as it is not obvious what the relative path base should be, e.g.

<#dataset> rdf:type      tdb:DatasetTDB ;
    tdb:location "/var/lib/jetty/webapps/joseki/TDB" ;

Of course, that path has to exist and be writable for the Jetty process, i.e. the jetty user.

With that configuration, it is finally possible to query the Joseki database at http://localhost:8080/joseki/sparql.