简体   繁体   中英

NoClassDefFoundError when using java impl of leveldb

for those who've managed to use this java implementation of leveldb https://github.com/dain/leveldb/

I'm getting the following stacktrace when I try to execute the code in the readme:

NoClassDefFoundError occurs when runing the following line:

DB db = factory.open(new File("example"), options);

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/Lists
at org.iq80.leveldb.impl.DbImpl.(DbImpl.java:95)
at org.iq80.leveldb.impl.Iq80DBFactory.open(Iq80DBFactory.java:59)
at com.test.LevelDBDain.main(LevelDBDain.java:23)
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Lists
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

I confirmed that new File("example") returns a non-null value; same as the variable options

I import two jars built from the source into my library:

1.leveldb-api.jar
2.leveldb.jar

I've tried this with releases 0.6, 0.7 and 0.8-SNAPSHOT and always get the same error.

Could it be something I'm doing wrong ...or missing?

来自guava的 com.google.common.collect.util是leveldb库的依赖项,但由于某种原因,将其显式添加为我的Java项目的依赖项解决了该问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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