voltrb / volt

A Ruby web framework where your Ruby runs on both server and client
MIT License
3.22k stars 196 forks source link

jRuby 9.0.0.0 support #267

Open Allanon29 opened 9 years ago

Allanon29 commented 9 years ago

I get this error when I try to access the homepage of a new volt app under jruby 9.0.0.0:

2015-08-16 09:31:48 +0200: Rack app error: #<NoMethodError: undefined method `getDescriptorByFileno' for #<Java::OrgJruby::Ruby:0x141ac0c5>>
/Users/Mate/.rbenv/versions/jruby-9.0.0.0/lib/ruby/gems/shared/gems/eventmachine-1.0.8-java/lib/eventmachine.rb:757:in `attach_io'
/Users/Mate/.rbenv/versions/jruby-9.0.0.0/lib/ruby/gems/shared/gems/eventmachine-1.0.8-java/lib/eventmachine.rb:745:in `attach'
/Users/Mate/.rbenv/versions/jruby-9.0.0.0/lib/ruby/gems/shared/gems/faye-websocket-0.9.2/lib/faye/rack_stream.rb:26:in `initialize'
/Users/Mate/.rbenv/versions/jruby-9.0.0.0/lib/ruby/gems/shared/gems/faye-websocket-0.9.2/lib/faye/websocket.rb:70:in `initialize'
/Users/Mate/.rbenv/versions/jruby-9.0.0.0/lib/ruby/gems/shared/gems/volt-0.9.4/lib/volt/server/websocket/websocket_handler.rb:21:in `call'
/Users/Mate/.rbenv/versions/jruby-9.0.0.0/lib/ruby/gems/shared/gems/rack-1.5.5/lib/rack/builder.rb:138:in `call'
/Users/Mate/.rbenv/versions/jruby-9.0.0.0/lib/ruby/gems/shared/gems/puma-2.12.3-java/lib/puma/server.rb:541:in `handle_request'
/Users/Mate/.rbenv/versions/jruby-9.0.0.0/lib/ruby/gems/shared/gems/puma-2.12.3-java/lib/puma/server.rb:388:in `process_client'
/Users/Mate/.rbenv/versions/jruby-9.0.0.0/lib/ruby/gems/shared/gems/puma-2.12.3-java/lib/puma/server.rb:270:in `block in run'
org/jruby/RubyProc.java:308:in `call'

I also get the following warn message: "[WARN] Code reloading in Volt currently depends on fork. Your environment does not support fork. We're working on adding more reloading strategies. For now though you'll need to restart the server manually on changes, which sucks. Feel free to complain to the devs, we really let you down here. :-)"

ryanstout commented 9 years ago

@Allanon29 we had things working in jruby, but its not officially supported yet. (Just haven't had time yet). The warning is saying that we don't have code reloading working in jruby yet (because we can't use forking like in MRI.) I want to implement class name based reloading like in rails, but its somewhat complicated and I'm trying to get the core stuff out the door first. For now I'm going to leave this open, I probably won't have time to get to this for a little while. Hopefully you can use MRI for a little while (In the past I ran most of my rails production stuff on jruby, so its a priority)

Ch4s3 commented 9 years ago

:+1: for class based reloading!

Allanon29 commented 9 years ago

@ryanstout Thanks for the reply. jRuby support would be great. Many things happening on that side as well, like jRuby 9.0.0.0 came out recently, and Torquebox 4 beta1 is out.

BTW found this on Stackoverflow ( http://stackoverflow.com/questions/11818463/alternative-for-spawning-a-process-with-fork-in-jruby ):

# To mimic the Process.fork in MRI Ruby
module JRubyProcess
  require 'ffi'
  extend FFI::Library
  ffi_lib FFI::Library::LIBC
  attach_function :fork, [], :int
end

pid = JRubyProcess.fork do
  #internal_server.run
end
ryanstout commented 9 years ago

Thanks. Forking on the JVM isn't really an option though. You can see even from the stack overflow post that it doesn't really work. If you want to work on Jruby support, it shouldn't be too hard. I'm happy to help if you have time. I just don't have time on my end right now. (Gotta get volt-sql out the door first)

On Fri, Aug 21, 2015 at 12:22 PM, Allanon29 notifications@github.com wrote:

@ryanstout https://github.com/ryanstout Thanks for the reply. jRuby support would be great. Many things happening on that side as well, like jRuby 9.0.0.0 came out recently, and Torquebox 4 beta1 is out.

BTW found this on Stackoverflow ( http://stackoverflow.com/questions/11818463/alternative-for-spawning-a-process-with-fork-in-jruby ): `# To mimic the Process.fork in MRI Ruby module JRubyProcess require 'ffi' extend FFI::Library ffi_lib FFI::Library::LIBC attach_function :fork, [], :int end

pid = JRubyProcess.fork do

internal_server.run

end`

— Reply to this email directly or view it on GitHub https://github.com/voltrb/volt/issues/267#issuecomment-133521977.