简体   繁体   English

执行OWLAPI时出错

[英]Getting error in executing OWLAPI

I am trying to create an ontology using owlapi in eclipse using owl-osgi-distribution 4.0.2 and getting an error of Noclassfound which is similar to the error as in the link 我正在尝试使用owl-osgi-distribution 4.0.2在Eclipse中使用owlapi创建一个本体,并得到Noclassfound错误,该错误类似于链接中的错误

Getting error in executing OWL API 执行OWL API时出错

and as per the error I was getting: 根据错误我得到:

Exception in thread "main" java.lang.NoClassDefFoundError:   
com/google/inject/Provider at java.lang.ClassLoader.defineClass1(Native  
Method) at java.lang.ClassLoader.defineClass(Unknown Source) at    
java.security.SecureClassLoader.defineClass(Unknown Source) at   
java.net.URLClassLoader.defineClass(Unknown Source) at 
java.net.URLClassLoader.access$100(Unknown Source) 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) at 
java.lang.ClassLoader.defineClass1(Native Method) at 
java.lang.ClassLoader.defineClass(Unknown Source) at 
java.security.SecureClassLoader.defineClass(Unknown Source) at 
java.net.URLClassLoader.defineClass(Unknown Source) at 
java.net.URLClassLoader.access$100(Unknown Source) 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) at test.main(test.java:18) 
Caused by: java.lang.ClassNotFoundException: com.google.inject.Provider 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) ... 25 more

With the answer in the link I understood that my owlapi files need to be added for which I referred at the following way to solve it. 有了链接中的答案,我了解到需要添加我的owlapi文件,我通过以下方式为其解决了问题。

http://www.jabenitez.com/2015/08/19/solucionando-el-error-java-lang-noclassdeffounderror-comgoogleinjectprovider/ http://www.jabenitez.com/2015/08/19/solucionando-el-error-java-lang-noclassdeffounderror-comgoogleinjectprovider/

I did the entire above procedure and when ran the code 我完成了上述整个过程,并在运行代码时

 package ontology;

 import java.io.File;
 import java.util.Set;

 import org.semanticweb.owlapi.apibinding.OWLManager;
 import org.semanticweb.owlapi.model.IRI;
 import org.semanticweb.owlapi.model.OWLAxiom;
 import org.semanticweb.owlapi.model.OWLOntology;
 import org.semanticweb.owlapi.model.OWLOntologyCreationException;
 import org.semanticweb.owlapi.model.OWLOntologyManager;

 public class Owlapitutorial {

    public static void main(String[] args) {
    // TODO Auto-generated method stub
    // load file
    File file = new File("F://Ankita//creatingOntology//ontofit.owl");

    // loading the ontology
    try {
        OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
        OWLOntology localOntology = manager.loadOntologyFromOntologyDocument(file);

        //getting all axioms    
        Set<OWLAxiom> axSet= localOntology.getAxioms();

        System.out.println(localOntology.getLogicalAxiomCount());

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

}

} }

After that my program gave me the following error 之后,我的程序给了我以下错误

 Exception in thread "main" java.lang.NoClassDefFoundError:   
org/slf4j/LoggerFactory
at org.semanticweb.owlapi.OWLAPIServiceLoaderModule.<clinit>  
(OWLAPIServiceLoaderModule.java:50)
at org.semanticweb.owlapi.apibinding.OWLManager.<clinit>(OWLManager.java:42)
at ontology.Owlapitutorial.main(Owlapitutorial.java:22)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
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)
... 3 more

I did understand and verified that one of the dependency file org.slf4j:slf4j-api:jar:1.7.7: was missing in the lib folder of owlosgi which I downloaded and added into the build path making a new library. 我确实理解并验证了依赖文件org.slf4j:slf4j-api:jar:1.7.7:之一在owlosgi的lib文件夹中丢失了,该文件夹已下载并添加到构建新库的构建路径中。

I also created a new file in my folder F://Ankita//creatingOntology//ontofit.owl and ran the program and now I am getting a different error ie 我还在文件夹F://Ankita//creatingOntology//ontofit.owl中创建了一个新文件,并运行了程序,现在我得到了另一个错误,即

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further    
details.
0

I have gone to StaticLoggerBinder site for further details and downloaded the zip file of SLF4J but I have no idea what am I supposed to do since there are many jar files in it. 我已访问StaticLoggerBinder网站以获取更多详细信息,并下载了SLF4J的zip文件,但由于其中包含许多jar文件,因此我不知道该怎么办。

Can anyone please help me. 谁能帮帮我吗。

Arc. 弧。

SLF4J provides a common interface to several alternative logging systems, but you haven't included any of them in your project, so it is defaulting to the NOP logger implementation. SLF4J为多个备用日志记录系统提供了一个通用接口,但是您的项目中未包含任何其他日志记录系统,因此它默认为NOP记录器实现。 If you want to implement more useful logging, you should include one of the alternatives suggested on the SLF4J page given in the error message ( http://www.slf4j.org/codes.html#StaticLoggerBinder ), such as Log4J. 如果要实现更有用的日志记录,则应包括错误消息( http://www.slf4j.org/codes.html#StaticLoggerBinder )中给出的SLF4J页面上建议的替代方法之一,例如Log4J。

Alternatively you can safely ignore that message, but you won't get any logging information if things go wrong. 另外,您可以放心地忽略该消息,但是如果出现问题,您将不会获得任何日志记录信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM