basically there are a lot of differences between a command line recommender and a web application.
First thing is the packaging. If you want your recommender to work as a web application you have to put all the necessary libs into the WEB-INF/lib directory. This has nothing todo with Mahout itself it is just how web applications work. In this email you will find the complete list of files how I package them in the facebook-recommender-demo.
You can open the facebook-recommender-demo directly in NetBeans and should be able to inspect it. So you have to tell NetBeans that you need the mahout libs. I am using maven to find the dependencies and maven does package them automatically including all transitive dependencies.
Next thing is life cycle of application. A command line recommender starts as a process does what it has to do and dies afterwards. A web application runs as part of the servlet container (tomcat, jetty, glassfish, etc.). This means that it will run for a long time. You should instantiate you recommender only once and then reuse it for all user requests. The recommender will use a lot of memory (in my tests about 0,2 kb per entry. meaning 60mb for 300.000 entries). As far as I know taste is thread safe. Therefore you need only one recommender in your whole web application server process. You do this in the init method. You can use a static variable and the singleton pattern. An alternative would be to put the recommender in the ServletContext by using set attribute function.
Here are some links of how to do this:
* http://docs.oracle.com/javaee/6/api/javax/servlet/ServletContext.html#setAttribute(java.lang.String, java.lang.Object)
Another difference is where to get your data from. I do not know if you are using a file, a database, cassandra, mongo db or any other source. I will expect that you are using a file. In a command line environment you can just pull your data from everywhere. In a web application this is far more complicated. The web application uses it own class loader and therefore it is searching resources in different places.
Again in https://github.com/ManuelB/facebook-recommender-demo/blob/master/src/main/java/de/apaxo/bedcon/FacebookRecommender.java I show how to read the values from a file which is prepacked in the web application.
138 // get the file which is part of the WAR as
139 URL url = getClass().getClassLoader().getResource(DATA_FILE_NAME);
141 // create a file out of the resource
142 File data = new File(url.toURI());
I hope that helps. If you need more help you can buy some professional support. For example my company (http://www.apaxo.de) is selling professional support. Feel free to concat me personally.
$ jar -tf facebook-recommender-demo.war
On 07.03.2012, at 22:52, Ben Brodie wrote: