I'm a new user of mahout. I have a problem about deploy a new recommender i
wrote at the last step: mvn jetty:run-war, the logs are as follows:

******logs begin*************************************
:WARN:/:unavailable
org.apache.mahout.cf.taste.common.TasteException:
java.lang.ClassNotFoundException: training.IntroRecommender
        at
org.apache.mahout.cf.taste.web.RecommenderSingleton.<init>(RecommenderSingleton.java:53)
******logs end*************************************

I want to know how to correctly configure the settings to make sure that
mahout can find the class file
(recommender.class=training.IntroRecommender).
Follow the example of grouplens instructions, I build it successful
(http://localhost:8080/RecommenderServlet?userID=1) on my one machine. My
problem is that the recommender I wrote can not build successfully. The
programs as follow:

***my program begin************************************
package training;

import java.io.*;
import java.util.*;

import org.apache.mahout.cf.taste.common.Refreshable;
import org.apache.mahout.cf.taste.common.TasteException;
import org.apache.mahout.cf.taste.impl.model.file.FileDataModel;
import
org.apache.mahout.cf.taste.impl.neighborhood.NearestNUserNeighborhood;
import
org.apache.mahout.cf.taste.impl.recommender.GenericUserBasedRecommender;
import
org.apache.mahout.cf.taste.impl.similarity.AveragingPreferenceInferrer;
import
org.apache.mahout.cf.taste.impl.similarity.PearsonCorrelationSimilarity;
import org.apache.mahout.cf.taste.model.DataModel;
import org.apache.mahout.cf.taste.neighborhood.UserNeighborhood;
import org.apache.mahout.cf.taste.recommender.IDRescorer;
import org.apache.mahout.cf.taste.recommender.RecommendedItem;
import org.apache.mahout.cf.taste.recommender.Recommender;
import org.apache.mahout.cf.taste.similarity.UserSimilarity;

public class IntroRecommender implements Recommender{
        private final Recommender recommender;
        public IntroRecommender() throws IOException,TasteException{
                this(new FileDataModel(new File("intro.csv")));
        }
        
        public IntroRecommender(DataModel model) throws TasteException{
                UserSimilarity userSimilarity=new 
PearsonCorrelationSimilarity(model);
                userSimilarity.setPreferenceInferrer(new
AveragingPreferenceInferrer(model));
                
                UserNeighborhood neighborhood=new
NearestNUserNeighborhood(3,userSimilarity,model);
                recommender=new
GenericUserBasedRecommender(model,neighborhood,userSimilarity);
        }
        
        //对外提供推荐接口,参数为用户标识和推荐项数目
        public List<RecommendedItem> recommend(long userID,int howMany) throws
TasteException{
                return recommender.recommend(userID,howMany);
        }
        
        public List<RecommendedItem> recommend(long userID,int 
howMany,IDRescorer
rescorer) throws TasteException{
                return recommender.recommend(userID,howMany,rescorer);
        }
        
        //以下方法都是实现Recommender的接口
        public float estimatePreference(long userID,long itemID) throws
TasteException{
                return recommender.estimatePreference(userID, itemID);
        }
        
        public void setPreference(long userID,long itemID,float value) throws
TasteException{
                recommender.setPreference(userID, itemID,value);
        }
        
        public void removePreference(long userID,long itemID) throws
TasteException{
                recommender.removePreference(userID, itemID);
        }
        
        public DataModel getDataModel(){
                return recommender.getDataModel();
        }
        
        public void refresh(Collection<Refreshable> alreadyRefreshed){
                recommender.refresh(alreadyRefreshed);
        }
        
        public String toString(){
                return "UserbasedRecommender[recommender:" + recommender + ']';
        }

}
***my program end************************************

my steps as follows:
1.put my data intro.csv and program IntroRecommender.class to one folder
like out;
2.build the jar file: jar cf intro.jar -C ./ .;
3. move the intro.jar to folder: ./mahout/taste-web/lib;
4. cd ./mahout/taste-web and edit the file recommender.properties:
recommender.class=training.IntroRecommender;
5. run: mvn package. A new .war file built at ./taste-web/target folder;
6. run: mvn jetty:run-war, but it run unsuccessfully and the logs means can
not find the .class file(training.IntroRecommender);

Wish my problem described clearly. Thanks so much.

Best regards
tianwild

--
View this message in context: 
http://lucene.472066.n3.nabble.com/how-to-deploy-my-new-recommender-tp3641633p3641633.html
Sent from the Mahout User List mailing list archive at Nabble.com.

Reply via email to