Using Mahout from JRuby raises "missing class or uppercase package name" for some classes

StackOverflow https://stackoverflow.com/questions/21587814

  •  07-10-2022
  •  | 
  •  

Question

I'm attempting to use Mahout in JRuby by requiring the following three JAR files from the latest stable Mahout distribution.

  • mahout-core-0.9.jar
  • mahout-integration-0.9.jar
  • mahout-math-0.9.jar

Some of the classes I'm trying to use work fine, but some in particular aren't loading. Instead I get exceptions like this one:

NameError: missing class or uppercase package name (`org.apache.mahout.cf.taste.impl.recommender.GenericBooleanPrefUserBasedRecommender')
  get_proxy_or_package_under_package at org/jruby/javasupport/JavaUtilities.java:54
                      method_missing at file:/Users/bloudermilk/.rbenv/versions/jruby-1.7.10/lib/jruby.jar!/jruby/java/java_package_module_template.rb:14
                              (root) at _test.rb:9

I'm sure that the class exists in the package, as it is mentioned in the docs. In fact I can also decompress the mahout-core JAR and see the respective .class file in there.

I uploaded a test repo to GitHub here: https://gist.github.com/bloudermilk/8832036

I don't have any Java experience so it seems likely I'm missing something obvious. Why isn't JRuby able to find this class? How can I remedy this?

Was it helpful?

Solution

When I tried this, I got an error like:

Java::OrgApacheMahoutCfTasteImplRecommender::GenericBooleanPrefUserBasedRecommender
NameError: cannot link Java class org.apache.mahout.cf.taste.impl.recommender.GenericBooleanPrefUserBasedRecommender, probable missing dependency:

My guess is that you don't have something on your classpath. I took the "big hammer" approach to get everything on the classpath and was able to get it to work:

Dir['./mahout/*jar'].each {|f| require f}
Dir['./mahout/lib/*jar'].each {|f| require f}
Java::OrgApacheMahoutCfTasteImplRecommender::GenericBooleanPrefUserBasedRecommender
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top