Jar库的NoClassDefFoundError

时间:2013-02-24 14:32:32

标签: java rdf sesame

我正在使用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

1 个答案:

答案 0 :(得分:0)

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

您的类路径中的download and configure classpath commons-httpclient-3.0.1.jar库。