0

I am learning to use mahout by starting with a example copied from the book. However, the eclipse compiler gives me the following message:

Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.apache.mahout.cf.taste.impl.model.file.FileDataModel.<clinit>(FileDataModel.java:119)
at mia.recommender.ch02.RecommenderIntro.main(RecommenderIntro.java:18)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 2 more

It seems to me that the the problem comes from FileDataModel.java, which belongs to this libary itself. How to trace back or analyze this error.

The example code is given as follows, which exactly is the one copied from the book. The line causing the trouble is

DataModel model = new FileDataModel(new File("intro.csv"));

import org.apache.mahout.cf.taste.impl.model.file.*;
import org.apache.mahout.cf.taste.impl.neighborhood.*;
import org.apache.mahout.cf.taste.impl.recommender.*;
import org.apache.mahout.cf.taste.impl.similarity.*;
import org.apache.mahout.cf.taste.model.*;
import org.apache.mahout.cf.taste.neighborhood.*;
import org.apache.mahout.cf.taste.recommender.*;
import org.apache.mahout.cf.taste.similarity.*;
import java.io.*;
import java.util.*;
class RecommenderIntro {
  public static void main(String[] args) throws Exception {
	
	
    DataModel model = new FileDataModel(new File("intro.csv")); 
    UserSimilarity similarity = new PearsonCorrelationSimilarity(model);
    UserNeighborhood neighborhood =
      new NearestNUserNeighborhood(2, similarity, model);
    Recommender recommender = new GenericUserBasedRecommender(
        model, neighborhood, similarity); 
    List<RecommendedItem> recommendations =
        recommender.recommend(1, 1); 
    for (RecommendedItem recommendation : recommendations) {
      System.out.println(recommendation);
    }
  }
}

Edited by winecoding: n/a

3
Contributors
2
Replies
4
Views
5 Years
Discussion Span
Last Post by thekashyap
0

the eclipse compiler gives me the following message:

Strange, looks like an execution error. But I don't know your IDE so maybe it is compiler.

java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory

Where is the class that is referred to in this error message?

0

Yeah, it looks like some class path issue and not exactly a compilation error.

Answer NormR's question..

java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory

Where is the class that is referred to in this error message?

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.