Created
February 19, 2009 00:09
-
-
Save bradheintz/66627 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Inheritance Weirdness: I can get a couple of different errors, but no correct behavior out of the following code: | |
#!/usr/bin/env jruby -d | |
require 'java' | |
require '/Users/bradheintz/project/hadoop/current/lib/commons-logging-1.0.4.jar' | |
require '/Users/bradheintz/project/hadoop/current/lib/log4j-1.2.15.jar' | |
require '/Users/bradheintz/project/hadoop/current/hadoop-0.18.1-core.jar' | |
class MyMapper < org.apache.hadoop.mapred.MapReduceBase | |
include org.apache.hadoop.mapred.Mapper | |
end | |
conf = org.apache.hadoop.mapred.JobConf.new | |
# The error I get depends on which of the following lines I end with. I need to call conf.setMapperClass(), which is defined thus: | |
# public void setMapperClass(Class<? extends Mapper> theClass) | |
# If I do this: | |
conf.setMapperClass(MyMapper) | |
# I get this error: | |
# org/apache/hadoop/conf/Configuration.java:697:in `setClass': java.lang.RuntimeException: class org.apache.hadoop.mapred.MapReduceBase not org.apache.hadoop.mapred.Mapper (NativeException) | |
# from org/apache/hadoop/mapred/JobConf.java:708:in `setMapperClass' | |
# from sun/reflect/NativeMethodAccessorImpl.java:-2:in `invoke0' | |
# from sun/reflect/NativeMethodAccessorImpl.java:39:in `invoke' | |
# from sun/reflect/DelegatingMethodAccessorImpl.java:25:in `invoke' | |
# from java/lang/reflect/Method.java:585:in `invoke' | |
# from org/jruby/javasupport/JavaMethod.java:298:in `invokeWithExceptionHandling' | |
# from org/jruby/javasupport/JavaMethod.java:259:in `invoke' | |
# from org/jruby/java/invokers/InstanceMethodInvoker.java:44:in `call' | |
# from org/jruby/runtime/callsite/CachingCallSite.java:280:in `cacheAndCall' | |
# from org/jruby/runtime/callsite/CachingCallSite.java:116:in `call' | |
# ...more stack elided... | |
# ...which looks like the inherited class is obscuring the interface. | |
# If I do this (which is closer to the actual Java call I'd use): | |
conf.setMapperClass(MyMapper.class) | |
# I get this error; | |
./implement.rb:18: for method setMapperClass expected [java.lang.Class]; got: [org.jruby.RubyClass]; error: argument type mismatch (TypeError) | |
# Fair enough, it wants a Java class. But when I use this: | |
conf.setMapperClass(MyMapper.java_class) | |
# ...I get the same Java stack trace as above. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment