1

I'm trying to use Jena 2.12.1 with Pellet; I downloaded the latest Apache Jena library from their site Jena 2.12.1.

First, I downloaded Pellet 2.3.1 and imported the JENA libraries. Unfortunately, org.mindswap.pellet.jena.PelletReasonerFactory couldn't be resolved, and thus, I couldn't instantiate a reasoner.

Then, I downloaded multiple versions the jar file pellet-jena-2.3.2 (tried 2.3.1 and 2.3.0). This resolved org.mindswap.pellet.jena.PelletReasonerFactory. However it caused the exception:

Exception in thread "main" java.lang.NoClassDefFoundError: org/mindswap/pellet/utils/progress/ProgressMonitor
at org.mindswap.pellet.jena.PelletReasoner.bind(PelletReasoner.java:95)
at org.mindswap.pellet.jena.PelletReasoner.bind(PelletReasoner.java:53)
at com.hp.hpl.jena.rdf.model.ModelFactory.createInfModel(ModelFactory.java:261)
at code.BasicOWLHandler.main(BasicOWLHandler.java:678)
Caused by: java.lang.ClassNotFoundException: org.mindswap.pellet.utils.progress.ProgressMonitor


at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 4 more

My code:

import org.mindswap.pellet.jena.PelletReasonerFactory;
import com.hp.hpl.jena.rdf.model.InfModel;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.reasoner.Reasoner;

public class Test {
public static void main (String [] args)
{
    Reasoner reasoner = PelletReasonerFactory.theInstance().create();

    // create an empty model
    Model emptyModel = ModelFactory.createDefaultModel( );

    // create an inferencing model using Pellet reasoner
    InfModel model = ModelFactory.createInfModel( reasoner, emptyModel );
}   
}

What is the problem? is there a better way to use jena 2.12.1 with Pellet (any version)?

eightShirt
  • 1,457
  • 2
  • 15
  • 29
Median Hilal
  • 1,483
  • 9
  • 17

3 Answers3

1

The error message says it can't find org.mindswap.pellet.utils.progress.ProgressMonitor when called from org.mindswap.pellet.jena.PelletReasoner.bind. That looks like the classpath does not have all the necessary Pellet jars. It is nothing to do with Jena.

However, see http://clarkparsia.com/pellet/faq/different-jena-version/. Pellet is unlikely to work perfectly with Jena 2.12.1 due to the 2+ year gap.

You may wish to try this fork or one of its branches: https://github.com/ansell/pellet (no recommendation either way)

The link you give to Jena is not the master site - it looks like a mirror of http://www.apache.org/dist/jena.

AndyS
  • 16,345
  • 17
  • 21
  • I checked the first link you provided; They say that each Pellet distribution contains a compatible JENA version. I downloaded and included the [Pellet 2.3.1] (http://clarkparsia.com/pellet/download/pellet-2.3.1) which also includes JENA 2.10; However I still have an unresolved import `org.mindswap.pellet.jena.PelletReasonerFactory`. This import can be resolved in pellet-jena jar file which I wonder why isn't it inclued in the Pellet distribution; so I had to import it from an external link and this causes the mentioned exception. However, I think this isn't the best way to solve the problem. – Median Hilal Feb 28 '15 at 18:00
1

If anybody comes across this and wants to use Jena 2.13 together with Pellet, it's possible since July 14, 2015 using Pellet 2.4. See commit #7b07bf.

Get get it up and running you just have to build the JARs yourself by cloning their repo and running mvn compile. They also include an example using Jena 2.13.

To use Pellet with Jena simple follow the instruction on their FAQs:

// ontology that will be used
String ont = "http://www.mindswap.org/2004/owl/mindswappers";

// create an empty ontology model using Pellet spec
OntModel model = ModelFactory.createOntologyModel( PelletReasonerFactory.THE_SPEC );   

// read the file
model.read( ont );
F Lekschas
  • 12,481
  • 10
  • 60
  • 72
0

Using pellet-2.3.0 (Aug 22, 2011) including JENA compatible librairies instead of pellet-2.3.1 has solved the problem.

Median Hilal
  • 1,483
  • 9
  • 17