Median Hilal Median Hilal - 6 days ago 6
Java Question

Using Jena with Pellet; NoClassDefFoundError Exception

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)?

Answer

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

Comments