我正在尝试执行以下代码。
import java.io.File;
import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.model.AddAxiom;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLAxiom;
import org.semanticweb.owlapi.model.OWLClass;
import org.semanticweb.owlapi.model.OWLDataFactory;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
import org.semanticweb.owlapi.model.OWLOntologyManager;
public class Snippet {
public static void main(String[] args) throws OWLOntologyCreationException {
File file = new File(
"file:///c/Users/DTN/Desktop/Final SubmissionFilteringMechanism_Ontology.owl");
OWLOntologyManager m = OWLManager.createOWLOntologyManager();
OWLDataFactory f = OWLManager.getOWLDataFactory();
OWLOntology o;
o = m.loadOntologyFromOntologyDocument(file);
OWLClass clsA = f.getOWLClass(IRI.create("urn:test#ClassA"));
OWLClass clsB = f.getOWLClass(IRI.create("urn:test#ClassB"));
OWLAxiom ax1 = f.getOWLSubClassOfAxiom(clsA, clsB);
AddAxiom addAxiom1 = new AddAxiom(o, ax1);
m.applyChange(addAxiom1);
for (OWLClass cls : o.getClassesInSignature()) {
System.out.println(cls.getIRI());
}
m.removeOntology(o);
}
}
它正在生成以下错误。
线程“主”中的异常java.lang.NoClassDefFoundError:com / google / inject /
Provider位于java.lang.ClassLoader.defineClass1(本机方法),位于java.lang.ClassLoader.defineClass(未知源),位于java.security.SecureClassLoader。
java.net.URLClassLoader.defineClass(Unknown Source)的java.net.URLClassLoader
$ 1.run $ 100。(Unknown Source)java.net.URLClassLoader $ 1.run(Unknown
Source)的java.net.URLClassLoader $ 1
.run(未知源),位于java.security.AccessController.doPrivileged(本地方法),位于java.net.URLClassLoader.findClass(未知源),位于java.lang.ClassLoader.loadClass(未知源),位于sun.misc.Launcher
$ AppClassLoader
java.lang.ClassLoader上的.loadClass(未知源)。java.lang.ClassLoader上的.loadClass(未知源)。java.net.URLClassLoader.access
$
100处的java.lang.ClassLoader.defineClass(未知源)处的defineClass1(本地方法)java.net.URLClassLoader.defineClass(未知源)处的java.security.SecureClassLoader.defineClass(未知源)处(未知来源)在java.net.URLClassLoader
$ 1.run(未知来源)在java.net.URLClassLoader $
1.run(java.security.AccessController.doPrivileged(本机方法)在java.net.URLClassLoader.findClass
(未知源)在java.lang.ClassLoader.loadClass(未知源)在sun.misc.Launcher $
AppClassLoader.loadClass(未知源)在java.lang.ClassLoader.loadClass(未知源)在test.main(test.java
:18)由以下原因引起:java.lang.ClassNotFoundException:com.google.inject.Provider位于java.net.URLClassLoader。java.lang.ClassLoader.loadClass的findClass(未知源)sun.misc.Launcher
$ AppClassLoader.loadClass的java.lang.ClassLoader.loadClass(未知源)… 25其他
请一些身体帮助我。提前致谢。
您要在类路径中包含哪些jar?
看来您缺少一些Google guice依赖项。我建议使用一些依赖管理工具,例如Maven或Gradle
例如,我通过使用Maven依赖关系解决了该问题
net.sourceforge.owlapi:owlapi-osgidistribution:4.0.2
在以Snippet类为主的Maven项目中。
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fake</groupId>
<artifactId>fake</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>net.sourceforge.owlapi</groupId>
<artifactId>owlapi-osgidistribution</artifactId>
<version>4.0.2</version>
</dependency>
</dependencies>
如果要在不使用依赖项管理器的情况下运行它,请确保在类路径中包含以下jar(以下列表是通过maven依赖项树命令获得的)
[INFO] \- net.sourceforge.owlapi:owlapi-osgidistribution:jar:4.0.2:compile
[INFO] +- org.openrdf.sesame:sesame-model:jar:2.7.12:compile
[INFO] | \- org.openrdf.sesame:sesame-util:jar:2.7.12:compile
[INFO] +- org.openrdf.sesame:sesame-rio-api:jar:2.7.12:compile
[INFO] +- org.openrdf.sesame:sesame-rio-languages:jar:2.7.12:compile
[INFO] +- org.openrdf.sesame:sesame-rio-datatypes:jar:2.7.12:compile
[INFO] +- org.openrdf.sesame:sesame-rio-binary:jar:2.7.12:compile
[INFO] +- org.openrdf.sesame:sesame-rio-n3:jar:2.7.12:compile
[INFO] +- org.openrdf.sesame:sesame-rio-nquads:jar:2.7.12:compile
[INFO] | \- commons-io:commons-io:jar:2.4:compile
[INFO] +- org.openrdf.sesame:sesame-rio-ntriples:jar:2.7.12:compile
[INFO] +- org.openrdf.sesame:sesame-rio-rdfjson:jar:2.7.12:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-core:jar:2.2.1:compile
[INFO] +- org.openrdf.sesame:sesame-rio-rdfxml:jar:2.7.12:compile
[INFO] +- org.openrdf.sesame:sesame-rio-trix:jar:2.7.12:compile
[INFO] +- org.openrdf.sesame:sesame-rio-turtle:jar:2.7.12:compile
[INFO] +- org.openrdf.sesame:sesame-rio-trig:jar:2.7.12:compile
[INFO] +- com.github.jsonld-java:jsonld-java-sesame:jar:0.5.0:compile
[INFO] | \- com.github.jsonld-java:jsonld-java:jar:0.5.0:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.3.3:compile
[INFO] | | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.3.0:compile
[INFO] | +- org.apache.httpcomponents:httpclient-cache:jar:4.2.5:compile
[INFO] | +- org.apache.httpcomponents:httpclient:jar:4.2.5:compile
[INFO] | | +- org.apache.httpcomponents:httpcore:jar:4.2.4:compile
[INFO] | | \- commons-codec:commons-codec:jar:1.6:compile
[INFO] | \- org.slf4j:jcl-over-slf4j:jar:1.7.7:runtime
[INFO] +- org.semarglproject:semargl-sesame:jar:0.6.1:compile
[INFO] | +- org.semarglproject:semargl-core:jar:0.6.1:compile
[INFO] | \- org.semarglproject:semargl-rdfa:jar:0.6.1:compile
[INFO] | \- org.semarglproject:semargl-rdf:jar:0.6.1:compile
[INFO] +- com.google.guava:guava:jar:18.0:compile
[INFO] +- com.google.inject:guice:jar:4.0-beta:compile
[INFO] | +- javax.inject:javax.inject:jar:1:compile
[INFO] | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- com.google.inject.extensions:guice-multibindings:jar:4.0-beta:compile
[INFO] +- com.google.code.findbugs:jsr305:jar:2.0.1:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.7:compile
[INFO] +- org.apache.directory.studio:org.apache.commons.io:jar:2.4:compile
[INFO] \- net.sf.trove4j:trove4j:jar:3.0.3:compile
我试图在eclipse中使用owlapi创建一个本体,使用owl-osgi-distribution 4.0.2并得到一个Noclassfound错误,与链接中的错误类似 根据我得到的错误: 有了链接中的答案,我明白了我的owlapi文件需要添加,为了解决这个问题,我参考了下面的方法。 http://www.jabenitez.com/2015/08/19/solucionando-el-erro
我刚遇到这个错误,它突然来了,破坏了我的项目。有没有人可以帮助我解决这个错误:
突然我开始得到这个错误,我不明白为什么如果有人让我知道这个错误在哪里,会有足够的帮助。因为android Studio的新更新,我能得到的就是这个。我得到的错误的详细摘要。
执行 时出错。 这是错误日志: 11-05 05:03:20.171:E/Android runtime(3171):致命异常:async task # 1 < br > 11-05 05:03:20.171:E/Android runtime(3171):Process:com . example . MySQL test,PID:3171 < br > 11-05 05:03:20.171:E
java.lang.RuntimeException:执行doInBackground()E/Android runtime(695)时出错:at Android . OS . async task $ 3 . done(async task . Java:200)E/Android runtime(695):at Java . util . concurrent . future task $
执行获取HQL查询时出现异常。查询大部分时间都有效,但有时会显示此异常 数据库是MySQL,使用的服务器是JBoss 5.1.0 GA 显示的错误是: 组织。冬眠例外GenericJDBCException:无法在组织上执行查询。冬眠例外SQLStateConverter。在组织中处理非特定异常(SQLStateConverter.java:126)。冬眠例外SQLStateConverter。o