猫头鹰api + pellet ignazio1977

时间:2016-04-09 15:44:31

标签: owl-api pellet

我在使用OWL-API运行Pellet时遇到问题。要调试代码,会抛出以下异常:

public class SemanticHelper{

private static final File file = new File("C:\\Users\\clayton\\Desktop\\testandoTopObjectProperty.owl");

public Set<OWLNamedIndividual> consultarInstanciasDeSuperClasse(String superClasse) {
    Set<OWLNamedIndividual> owlNamedIndividual = null;
    OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
    OWLOntology ontology;
    try {
        ontology = manager.loadOntologyFromOntologyDocument(IRI.create(file));
        OWLReasonerFactory reasonerFactory = PelletReasonerFactory.getInstance();
        OWLReasoner reasoner = reasonerFactory.createReasoner(ontology, new SimpleConfiguration());
        OWLClass owlClass =                 
                ontology
                .getOWLOntologyManager()
                .getOWLDataFactory()
                .getOWLClass(
                        IRI.create(Configuracoes.getIriBase() + "#" + superClasse));

        reasoner.precomputeInferences();

        Set<OWLClass> classes = reasoner.getSubClasses(owlClass, false).getFlattened();
        System.out.println(classes);

    } catch (OWLOntologyCreationException e) {
        e.printStackTrace();
    }

    return owlNamedIndividual;
}

public static void main(String args[]){
    SemanticHelper semanticHelper = new SemanticHelper();
    semanticHelper.consultarInstanciasDeSuperClasse("IntervaloDeDias");
}

}

下一行抛出异常

OWLReasoner reasoner = reasonerFactory.createReasoner(ontology,new SimpleConfiguration());

Exception in thread "main" java.lang.NoSuchMethodError: org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom.getProperty()Lorg/semanticweb/owlapi/model/OWLObjectPropertyExpression;
    at com.clarkparsia.pellet.owlapiv3.PelletVisitor.visit(PelletVisitor.java:478)
    at uk.ac.manchester.cs.owl.owlapi.OWLObjectSomeValuesFromImpl.accept(OWLObjectSomeValuesFromImpl.java:100)
    at com.clarkparsia.pellet.owlapiv3.PelletVisitor.visit(PelletVisitor.java:419)
    at uk.ac.manchester.cs.owl.owlapi.OWLObjectIntersectionOfImpl.accept(OWLObjectIntersectionOfImpl.java:90)
    at com.clarkparsia.pellet.owlapiv3.PelletVisitor.visit(PelletVisitor.java:1136)
    at uk.ac.manchester.cs.owl.owlapi.OWLObjectPropertyRangeAxiomImpl.accept(OWLObjectPropertyRangeAxiomImpl.java:107)
    at com.clarkparsia.pellet.owlapiv3.PelletVisitor.visit(PelletVisitor.java:839)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyImpl.accept(OWLOntologyImpl.java:1516)
    at com.clarkparsia.pellet.owlapiv3.PelletReasoner.refresh(PelletReasoner.java:967)
    at com.clarkparsia.pellet.owlapiv3.PelletReasoner.<init>(PelletReasoner.java:345)
    at com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory.createReasoner(PelletReasonerFactory.java:69)
    at com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory.createReasoner(PelletReasonerFactory.java:33)
    at br.com.ontologia.SemanticHelper.consultarInstanciasDeSuperClasse(SemanticHelper.java:58)
    at br.com.ontologia.SemanticHelper.main(SemanticHelper.java:94)

的pom.xml:

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>net.sourceforge.owlapi</groupId>
        <artifactId>pellet-core-ignazio1977</artifactId>
        <version>2.4.0-ignazio1977</version>
    </dependency>

    <dependency>
        <groupId>net.sourceforge.owlapi</groupId>
        <artifactId>owlapi-distribution</artifactId>
        <version>4.1.3</version>
    </dependency>

    <dependency>
        <groupId>net.sourceforge.owlapi</groupId>
        <artifactId>pellet-owlapi-ignazio1977</artifactId>
        <version>2.4.0-ignazio1977</version>
    </dependency>

    <dependency>
        <groupId>asm</groupId>
        <artifactId>asm</artifactId>
        <version>3.3.1</version>
    </dependency>

    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-bundle</artifactId>
        <version>1.19</version>
    </dependency>

    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20140107</version>
    </dependency>

    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-server</artifactId>
        <version>1.19</version>
    </dependency>

    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-core</artifactId>
        <version>1.19</version>
    </dependency>

</dependencies>

有人可以给我任何关于如何解决这个问题的提示吗?

我的类路径的主要文件

owlapi-distribution-4.1.3
pellet-core-ignazio1977
pellet-owlapi-ignazio1977-2.4.0
pellet-query-ignazio1977-2.4.0
pellet-jena-ignazio1977-2.4.0
jena-arq-2.10.1
jena-core-2.10.1

System.out.println的结果(System.getProperty(&#34; java.class.path&#34;));

C:\Users\clayton\workspace\SemanticMDX\target\classes;
C:\apache-tomcat-7.0.34\lib\annotations-api.jar;
C:\apache-tomcat-7.0.34\lib\catalina-ant.jar;
C:\apache-tomcat-7.0.34\lib\catalina-ha.jar;
C:\apache-tomcat-7.0.34\lib\catalina-tribes.jar;
C:\apache-tomcat-7.0.34\lib\catalina.jar;
C:\apache-tomcat-7.0.34\lib\ecj-4.2.1.jar;
C:\apache-tomcat-7.0.34\lib\el-api.jar;
C:\apache-tomcat-7.0.34\lib\jasper-el.jar;
C:\apache-tomcat-7.0.34\lib\jasper.jar;
C:\apache-tomcat-7.0.34\lib\jsp-api.jar;
C:\apache-tomcat-7.0.34\lib\owlapi-distribution-3.5.2.jar;
C:\apache-tomcat-7.0.34\lib\servlet-api.jar;
C:\apache-tomcat-7.0.34\lib\tomcat-api.jar;
C:\apache-tomcat-7.0.34\lib\tomcat-coyote.jar;
C:\apache-tomcat-7.0.34\lib\tomcat-dbcp.jar;
C:\apache-tomcat-7.0.34\lib\tomcat-i18n-es.jar;
C:\apache-tomcat-7.0.34\lib\tomcat-i18n-fr.jar;
C:\apache-tomcat-7.0.34\lib\tomcat-i18n-ja.jar;
C:\apache-tomcat-7.0.34\lib\tomcat-jdbc.jar;
C:\apache-tomcat-7.0.34\lib\tomcat-util.jar;
C:\Users\clayton\.m2\repository\net\sourceforge\owlapi\pellet-core-ignazio1977\2.4.0-ignazio1977\pellet-core-ignazio1977-2.4.0-ignazio1977.jar;
C:\Users\clayton\.m2\repository\com\github\ansell\aterms\aterm-java\1.8.2-p1\aterm-java-1.8.2-p1.jar;
C:\Users\clayton\.m2\repository\com\github\ansell\jjtraveler\jjtraveler\0.6\jjtraveler-0.6.jar;
C:\Users\clayton\.m2\repository\com\github\ansell\aterms\shared-objects\1.4.9-p1\shared-objects-1.4.9-p1.jar;
C:\Users\clayton\.m2\repository\org\jgrapht\jgrapht-jdk1.5\0.7.3\jgrapht-jdk1.5-0.7.3.jar;
C:\Users\clayton\.m2\repository\xerces\xercesImpl\2.11.0\xercesImpl-2.11.0.jar;
C:\Users\clayton\.m2\repository\xml-apis\xml-apis\1.4.01\xml-apis-1.4.01.jar;
C:\Users\clayton\.m2\repository\org\apache\jena\jena-arq\2.10.1\jena-arq-2.10.1.jar;
C:\Users\clayton\.m2\repository\org\apache\jena\jena-core\2.10.1\jena-core-2.10.1.jar;
C:\Users\clayton\.m2\repository\org\apache\jena\jena-iri\0.9.6\jena-iri-0.9.6.jar;
C:\Users\clayton\.m2\repository\org\apache\httpcomponents\httpclient\4.2.3\httpclient-4.2.3.jar;
C:\Users\clayton\.m2\repository\org\apache\httpcomponents\httpcore\4.2.2\httpcore-4.2.2.jar;
C:\Users\clayton\.m2\repository\commons-codec\commons-codec\1.6\commons-codec-1.6.jar;
C:\Users\clayton\.m2\repository\net\sourceforge\owlapi\owlapi-distribution\4.1.3\owlapi-distribution-4.1.3.jar;
C:\Users\clayton\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.5.1\jackson-core-2.5.1.jar;
C:\Users\clayton\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.5.1\jackson-databind-2.5.1.jar;
C:\Users\clayton\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.5.1\jackson-annotations-2.5.1.jar;
C:\Users\clayton\.m2\repository\org\tukaani\xz\1.5\xz-1.5.jar;
C:\Users\clayton\.m2\repository\org\openrdf\sesame\sesame-model\2.7.12\sesame-model-2.7.12.jar;
C:\Users\clayton\.m2\repository\org\openrdf\sesame\sesame-util\2.7.12\sesame-util-2.7.12.jar;
C:\Users\clayton\.m2\repository\org\openrdf\sesame\sesame-rio-api\2.7.12\sesame-rio-api-2.7.12.jar;
C:\Users\clayton\.m2\repository\org\openrdf\sesame\sesame-rio-languages\2.7.12\sesame-rio-languages-2.7.12.jar;
C:\Users\clayton\.m2\repository\org\openrdf\sesame\sesame-rio-datatypes\2.7.12\sesame-rio-datatypes-2.7.12.jar;
C:\Users\clayton\.m2\repository\org\openrdf\sesame\sesame-rio-binary\2.7.12\sesame-rio-binary-2.7.12.jar;
C:\Users\clayton\.m2\repository\org\openrdf\sesame\sesame-rio-n3\2.7.12\sesame-rio-n3-2.7.12.jar;
C:\Users\clayton\.m2\repository\org\openrdf\sesame\sesame-rio-nquads\2.7.12\sesame-rio-nquads-2.7.12.jar;
C:\Users\clayton\.m2\repository\org\openrdf\sesame\sesame-rio-ntriples\2.7.12\sesame-rio-ntriples-2.7.12.jar;
C:\Users\clayton\.m2\repository\org\openrdf\sesame\sesame-rio-rdfjson\2.7.12\sesame-rio-rdfjson-2.7.12.jar;
C:\Users\clayton\.m2\repository\org\openrdf\sesame\sesame-rio-rdfxml\2.7.12\sesame-rio-rdfxml-2.7.12.jar;
C:\Users\clayton\.m2\repository\org\openrdf\sesame\sesame-rio-trix\2.7.12\sesame-rio-trix-2.7.12.jar;
C:\Users\clayton\.m2\repository\org\openrdf\sesame\sesame-rio-turtle\2.7.12\sesame-rio-turtle-2.7.12.jar;
C:\Users\clayton\.m2\repository\org\openrdf\sesame\sesame-rio-trig\2.7.12\sesame-rio-trig-2.7.12.jar;
C:\Users\clayton\.m2\repository\com\github\jsonld-java\jsonld-java-sesame\0.5.0\jsonld-java-sesame-0.5.0.jar;
C:\Users\clayton\.m2\repository\com\github\jsonld-java\jsonld-java\0.5.0\jsonld-java-0.5.0.jar;
C:\Users\clayton\.m2\repository\org\apache\httpcomponents\httpclient-cache\4.2.5\httpclient-cache-4.2.5.jar;
C:\Users\clayton\.m2\repository\org\slf4j\jcl-over-slf4j\1.7.7\jcl-over-slf4j-1.7.7.jar;
C:\Users\clayton\.m2\repository\org\semarglproject\semargl-sesame\0.6.1\semargl-sesame-0.6.1.jar;
C:\Users\clayton\.m2\repository\org\semarglproject\semargl-core\0.6.1\semargl-core-0.6.1.jar;
C:\Users\clayton\.m2\repository\org\semarglproject\semargl-rdfa\0.6.1\semargl-rdfa-0.6.1.jar;
C:\Users\clayton\.m2\repository\org\semarglproject\semargl-rdf\0.6.1\semargl-rdf-0.6.1.jar;
C:\Users\clayton\.m2\repository\net\sf\trove4j\trove4j\3.0.3\trove4j-3.0.3.jar;
C:\Users\clayton\.m2\repository\com\google\guava\guava\18.0\guava-18.0.jar;
C:\Users\clayton\.m2\repository\com\google\inject\guice\4.0\guice-4.0.jar;
C:\Users\clayton\.m2\repository\javax\inject\javax.inject\1\javax.inject-1.jar;
C:\Users\clayton\.m2\repository\aopalliance\aopalliance\1.0\aopalliance-1.0.jar;
C:\Users\clayton\.m2\repository\com\google\inject\extensions\guice-assistedinject\4.0\guice-assistedinject-4.0.jar;
C:\Users\clayton\.m2\repository\com\google\inject\extensions\guice-multibindings\4.0\guice-multibindings-4.0.jar;
C:\Users\clayton\.m2\repository\com\google\code\findbugs\jsr305\2.0.1\jsr305-2.0.1.jar;
C:\Users\clayton\.m2\repository\org\slf4j\slf4j-api\1.7.10\slf4j-api-1.7.10.jar;
C:\Users\clayton\.m2\repository\commons-io\commons-io\2.4\commons-io-2.4.jar;
C:\Users\clayton\.m2\repository\net\sourceforge\owlapi\pellet-owlapi-ignazio1977\2.4.0-ignazio1977\pellet-owlapi-ignazio1977-2.4.0-ignazio1977.jar;
C:\Users\clayton\.m2\repository\net\sourceforge\owlapi\pellet-query-ignazio1977\2.4.0-ignazio1977\pellet-query-ignazio1977-2.4.0-ignazio1977.jar;
C:\Users\clayton\.m2\repository\net\sourceforge\owlapi\pellet-jena-ignazio1977\2.4.0-ignazio1977\pellet-jena-ignazio1977-2.4.0-ignazio1977.jar;
C:\Users\clayton\.m2\repository\org\antlr\antlr-runtime\3.4\antlr-runtime-3.4.jar;
C:\Users\clayton\.m2\repository\org\antlr\stringtemplate\3.2.1\stringtemplate-3.2.1.jar;
C:\Users\clayton\.m2\repository\antlr\antlr\2.7.7\antlr-2.7.7.jar;
C:\Users\clayton\.m2\repository\asm\asm\3.3.1\asm-3.3.1.jar;
C:\Users\clayton\.m2\repository\com\sun\jersey\jersey-bundle\1.19\jersey-bundle-1.19.jar;
C:\Users\clayton\.m2\repository\javax\ws\rs\jsr311-api\1.1.1\jsr311-api-1.1.1.jar;
C:\Users\clayton\.m2\repository\org\json\json\20140107\json-20140107.jar;
C:\Users\clayton\.m2\repository\com\sun\jersey\jersey-server\1.19\jersey-server-1.19.jar;
C:\Users\clayton\.m2\repository\com\sun\jersey\jersey-core\1.19\jersey-core-1.19.jar

1 个答案:

答案 0 :(得分:0)

根据javadoc,自3.5.0版以来,未找到的方法已成为OWLAPI的一部分。这似乎表明你在类路径上有多个OWLAPI jar,但你的pom没有显示它们。

您应该检查以确保只有这些库在您的实际运行时类路径中 - 这是作为maven构建的一部分运行,还是在类路径可能包含其他依赖项的另一个环境中运行?