Exception in thread "main" java.lang.NoSuchMethodError in Lenskit for Java

285 Views Asked by At

I am researching with Lenskit for Java, I wanna load file with CSV file. I using TextEntitySource to load source but I got error.

import java.io.File;
import java.io.IOException;

import org.lenskit.data.dao.file.TextEntitySource;

public class MainCTF {
    public static void main(String[] args) throws IOException {
        TextEntitySource entitySource = new TextEntitySource();
        File file = new File("D:\\newdocres\\dataset\\item_feature_matrix.csv");
        entitySource.setFile(file.toPath());
    }
}
Exception in thread "main" java.lang.NoSuchMethodError: 'com.google.common.io.ByteSource org.grouplens.lenskit.util.io.LKFileUtils.byteSource(java.io.File, org.grouplens.lenskit.util.io.CompressionMode)'
    at org.lenskit.data.dao.file.TextEntitySource.setFile(TextEntitySource.java:107)
    at main.MainCTF.main(MainCTF.java:17)

So How to can load a file CSV or using JDBC in Lenskit for java

1

There are 1 best solutions below

3
On

LensKit maintainer here.

I am not sure what precisely is happening with this error. It doesn't look like one of the usual failure modes, but @Stephen-C's suggestion that it is a dependency mismatch sounds likely. The dependencies should all match if you're getting them from Maven Central with either Maven or Gradle, but it's worth checking a full dependency list for your project to make sure you have the right versions.

LensKit for Java has not been maintained since 2018, and was last known to work on Java 8. In Java 9, Oracle broke Java's backwards compatibility in ways that affected LensKit, and I was not able to find a solution before shifting development and maintenance effort to LensKit for Python. If you really need to use the Java version, and the dependencies are correct, try with Java 8 (so long as the application isn't network-facing).