[Pellet-users] null pointer exception at getIndividuals()
Michael Smith
msmith at clarkparsia.com
Tue Jul 1 10:50:11 UTC 2008
On Wed, 2008-06-18 at 23:26 +0200, Alexander Becker wrote:
> I want to fetch all individuals of an ontology, that have a certain property.
> Unfortunately, I get one of these ugly null pointer exceptions, and as usual, I don't have any idea where the error comes from (no, the line number is no sufficent information :>).
> This is the error:
> java.lang.NullPointerException
> at org.mindswap.pellet.owlapi.PelletVisitor.addSimpleProperty(PelletVisitor.java:220)
> at org.mindswap.pellet.owlapi.PelletVisitor.visit(PelletVisitor.java:683)
> at uk.ac.manchester.cs.owl.OWLObjectSelfRestrictionImpl.accept(OWLObjectSelfRestrictionImpl.java:53)
> at org.mindswap.pellet.owlapi.PelletLoader.term(PelletLoader.java:173)
> at org.mindswap.pellet.owlapi.Reasoner.getIndividuals(Reasoner.java:550)
> at Test.ReasonerTest.get_ind_by_props_depr(ReasonerTest.java:270)
> And here is the code:
> OWLDataFactory factory = OWLManager.createOWLOntologyManager().getOWLDataFactory();
> OWLObjectProperty objectprop = factory.getOWLObjectProperty(URI.create(url + "#hasCase"));
> OWLObjectSelfRestriction clsC = factory.getOWLObjectSelfRestriction(objectprop);
>
> Set result2 = reasoner.getIndividuals(clsC, false); // line 270 here
> System.out.println("get_ind_by_props_depr: " + result2.toString());
> Maybe someone sees the error and / or may help me with that task.
The NPE is happening because the object property named url + "#hasCase"
hasn't been added to the reasoner (i.e., it doesn't appear in the loaded
ontology). As a result, attempt to create the self restriction class
description fails.
Consider trying the code with an object property returned by the
reasoner or explicitly adding an OWLDeclarationAxiom for the object
property you're using.
--
Mike Smith
Clark & Parsia
More information about the Pellet-users
mailing list