0

我正在使用 Sesame 访问示例 RDF 存储库,

String sesameServer = "http://asimov.ludat.lth.se/openrdf-sesame/";
String repositoryID = "KnowRob";
// Cannot create HTTPRepository
Repository myRepository = new HTTPRepository(sesameServer,repositoryID);
myRepository.initialize();
RepositoryConnection con = myRepository.getConnection();

但是,在尝试运行上面的代码时,我得到了 NoClassDefFoundError。

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/httpclient/Credentials
    at org.openrdf.repository.http.HTTPRepository.<init>(HTTPRepository.java:54)
    at org.openrdf.repository.http.HTTPRepository.<init>(HTTPRepository.java:59)
    at RDF.Start.main(Start.java:30)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.httpclient.Credentials
    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)
    ... 3 more
4

1 回答 1

0

当在用户定义的类和定义的类路径外部 jar 中找不到使用的类时,会发生 NoClassDefFoundError 异常。

因此,请在您的类路径中下载并配置类路径 commons-httpclient-3.0.1.jar库。

于 2017-05-13T03:41:16.203 回答