Fuseki using Pellet Inference

So I am sure that people are using this in the wild. I’m sure there is a good reason to want to do it, and possibly there is a quicker, easier way to do it – but I couldn’t find it!

Firstly you need to update your Fuseki configuration to add/modify the Reasoner to your Model. If you haven’t looked at the configuration it is referred to as an Assembler and sparse documentation can be found on the Jena site here (Your best bet is probably to download Fuseki and look at the bundled configuration examples). You may have a section in your configuration that looks like this:

<#model_inf> a ja:InfModel ;
ja:baseModel <#tdbGraph> ;
ja:reasoner [
ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLFBRuleReasoner >;
]
.

Which defines an Inference Model using the built in OWL Reasoner. Without exerting too much energy you can modify one line to update the Jena Reasoner to the Pellet Reasoner:

<#model_inf> a ja:InfModel ;
ja:baseModel <#tdbGraph> ;
ja:reasoner [
ja:reasonerClass “org.mindswap.pellet.jena.PelletReasonerFactory”;
]
.

If you did not previously have an inference model, you can add the configuration as above and put a reference to your existing graph (probably defined by a triple with predicate rdf:type and object tdb:GraphTDB) where I have <#tdbGraph>. Make sure to reference <#model_inf> in your service rather than <#tdbGraph> or the inference will not be utilised.

Fire up Fuseki and you will be presented with an exception Caused by: java.lang.ClassNotFoundException: org.mindswap.pellet.jena.PelletReasonerFactory . OK, we need to add Pellet to our classpath, but we don’t want it gloablly. A quick look inside fuseki-server.bat shows that it is just running the Fuseki jar with a chunk of memory. If we open up the jar and read the manifest (META-INF/MANIFEST.MF) then we can see the entry:

Main-Class: org.apache.jena.fuseki.FusekiCmd

This means we can craft an equivalent batch file to run the jar with a single line:

java -Xmx1200M -cp “./fuseki-server.jar” org.apache.jena.fuseki.FusekiCmd %*

Now that we have access to the classpath, we can add things to it. I started by creating a folder called ‘lib’ in the Fuseki install directory. I then downloaded Pellet 2.3.1 from Clark&Parsia here, opened it up and copied the list of jar files below (these are sufficient for a basic configuration, you may need others, but I haven’t yet)  into the lib folder:

aterm-java-1.6.jar
pellet-core.jar
pellet-datatypes.jar
pellet-el.jar
pellet-jena.jar (this jar actually contains the Reasoner)
pellet-rules.jar

Finally I modified the batch file so that it would add all jars in the lib folder to the classpath:

java -Xmx1200M -cp “./fuseki-server.jar;libs/*” org.apache.jena.fuseki.FusekiCmd %*

caveat: this is a windows only command, change the ; to a : for it to work on *nix environments.

This would have worked first time, but it seems that Fuseki 0.2.7 is bundling Jena 2.10.1 which if you have seen my other post does not play nicely with Pellet. So, for now, you are restricted to using Fuseki 0.2.7 or forking and rebuilding either Jena or Pellet yourself.

Leave a comment