Report abuse

DRb Server, run in JRuby


			
include Java
require 'drb' 
class TestServer 
  def add(*args) 
    args.inject {|n,v| n + v} 
  end 

  def method_missing(methodname, *args)
    klass = methodname.to_s
    methodd = args.delete_at(0)
    puts args.inspect
    puts methodd
    puts args.inspect
    the_script = "#{klass}.#{methodd}(*args)"
    puts the_script
    instance_eval(the_script)
  end
end 
server = TestServer.new 
DRb.start_service('druby://localhost:9000', server) 
DRb.thread.join # Don't exit just yet!

DRb client


			
require 'drb' 
DRb.start_service() 
obj = DRbObject.new(nil, 'druby://localhost:9000') 
puts obj.java.lang.System.getProperties["java.runtime.version"]

When the client is run in JRuby


			
1.5.0_13-b05-241

when the client is run in MRI 1.8.6


			
TypeError: wrong argument type String (expected Module)
        from (druby://localhost:9000) /Users/stephen/dev/jruby_trunk/jruby/lib/ruby/1.8/drb/drb.rb:1538:in `check_insecure_method'
        from (druby://localhost:9000) /Users/stephen/dev/jruby_trunk/jruby/lib/ruby/1.8/drb/drb.rb:1543:in `setup_message'
        from (druby://localhost:9000) /Users/stephen/dev/jruby_trunk/jruby/lib/ruby/1.8/drb/drb.rb:1494:in `perform'
        from (druby://localhost:9000) /Users/stephen/dev/jruby_trunk/jruby/lib/ruby/1.8/drb/drb.rb:1589:in `main_loop'
        from (druby://localhost:9000) /Users/stephen/dev/jruby_trunk/jruby/lib/ruby/1.8/drb/drb.rb:1585:in `loop'
        from (druby://localhost:9000) /Users/stephen/dev/jruby_trunk/jruby/lib/ruby/1.8/drb/drb.rb:1585:in `main_loop'
        from (druby://localhost:9000) /Users/stephen/dev/jruby_trunk/jruby/lib/ruby/1.8/drb/drb.rb:1585:in `accept'
        from (irb):4