I've just published an article on how I'm using DRb to command JRuby
from MRI:
http://rosenfeld.herokuapp.com/en/articles/ruby-rails/2013-07-16-running-java-from-mri-ruby-through-drb
I'd appreciate any feedbacks on how to avoid the mentioned warning,
since I need to include that DRb::DRbUndumped module, at least for byte
arrays.
Thanks in advance,
Rodrigo.
Em 16-07-2013 07:57, Rodrigo Rosenfeld Rosas escreveu:
if I extend the byte[] with DRb::DRbUndumped it works but I get a
warning in the server application:
server.rb:9 warning: singleton on non-persistent Java type
#<Class:0x4d7c1b64> (http://wiki.jruby.org/Persistence)
Em 16-07-2013 07:44, Rodrigo Rosenfeld Rosas escreveu:
Why isn't it possible to pass byte[] back to JRuby DRb server? I
believe it should be passed by reference, right?
Here's an example code:
server.rb
require 'drb/drb'
class Service
def to_java_bytes(str)
str.to_java_bytes
end
def from_java_bytes(bytes)
String.from_java_bytes bytes
end
end
service = Service.new
p service.from_java_bytes service.to_java_bytes 'Test'
DRb.start_service "druby://localhost:8787", Service.new
DRb.thread.join
client.rb
require 'drb/drb'
DRb.start_service
service = DRbObject.new_with_uri "druby://localhost:8787"
p service.from_java_bytes service.to_java_bytes 'Test'
Running the client with JRuby, I get this stacktrace:
TypeError: can't retrieve anonymous class #<Class:0x2b753bb9>
load at org/jruby/RubyMarshal.java:148
load at
/home/rodrigo/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/drb/drb.rb:626
synchronize at org/jruby/ext/thread/Mutex.java:149
load at
/home/rodrigo/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/drb/drb.rb:622
recv_reply at
/home/rodrigo/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/drb/drb.rb:674
recv_reply at
/home/rodrigo/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/drb/drb.rb:959
send_message at
/home/rodrigo/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/drb/drb.rb:1238
method_missing at
/home/rodrigo/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/drb/drb.rb:1129
open at
/home/rodrigo/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/drb/drb.rb:1213
method_missing at
/home/rodrigo/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/drb/drb.rb:1128
with_friend at
/home/rodrigo/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/drb/drb.rb:1146
method_missing at
/home/rodrigo/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/drb/drb.rb:1127
(root) at client.rb:7
Running with MRI 2.0.0 I get this stacktrace:
(druby://localhost:8787) org/jruby/RubyMarshal.java:148:in `load':
can't retrieve anonymous class #<Class:0x2b753bb9> (TypeError)
from (druby://localhost:8787)
/home/rodrigo/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/drb/drb.rb:530:in
`_load'
from (druby://localhost:8787)
org/jruby/RubyMarshal.java:148:in `load'
from (druby://localhost:8787)
/home/rodrigo/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/drb/drb.rb:626:in
`load'
from (druby://localhost:8787)
org/jruby/ext/thread/Mutex.java:149:in `synchronize'
from (druby://localhost:8787)
/home/rodrigo/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/drb/drb.rb:622:in
`load'
from (druby://localhost:8787)
/home/rodrigo/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/drb/drb.rb:660:in
`recv_request'
from (druby://localhost:8787)
org/jruby/RubyFixnum.java:285:in `times'
from (druby://localhost:8787)
/home/rodrigo/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/drb/drb.rb:659:in
`recv_request'
from (druby://localhost:8787)
/home/rodrigo/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/drb/drb.rb:949:in
`recv_request'
from (druby://localhost:8787)
/home/rodrigo/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/drb/drb.rb:1564:in
`init_with_client'
from (druby://localhost:8787)
/home/rodrigo/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/drb/drb.rb:1576:in
`setup_message'
from (druby://localhost:8787)
/home/rodrigo/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/drb/drb.rb:1528:in
`perform'
from (druby://localhost:8787)
/home/rodrigo/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/drb/drb.rb:1627:in
`main_loop'
from (druby://localhost:8787)
org/jruby/RubyKernel.java:1489:in `loop'
from (druby://localhost:8787)
/home/rodrigo/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/drb/drb.rb:1623:in
`main_loop'
from client.rb:7:in `<main>'
Is there any work-around that would allow me to pass byte[] back to
the server?
Thanks in advance,
Rodrigo.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email