#13 open
Kevin Williams

get working on JRuby

Reported by Kevin Williams | January 20th, 2008 @ 12:52 PM | in Future

discussed/requested on #thin

need ragel to output java, need to port thin.c to java(?), need to use either pure ruby version of EM or new java version of EM, or perhaps http://mina.apache.org/ for sockets

Comments and changes to this ticket

  • macournoyer

    macournoyer January 20th, 2008 @ 04:10 PM

    • State changed from “new” to “hold”

    How many ppl are gonna use this?

    I'm reluctant to do to this because it will require maintaining twice more code, in 2 languages. Mongrel already has a Java parser but we need to port all the changes to it. Plus I'm porting some parts of response writing to C. Writing extensions is already painful, writing it in 2 languages will be even more.

    If you'd like to use Thin on JRuby in production +1 the ticket. I'm putting on hold until I see lots of interest.

  • gary

    gary February 18th, 2008 @ 09:39 PM

    +1 - We're using JRuby and looking for the best way to deploy. Thin looks great but it would have to support jRuby.

  • Kevin Williams

    Kevin Williams February 18th, 2008 @ 09:53 PM

    I'm still trying to get Ruby allowed at work, and JRuby is probably the runtime I'd have to use. Count me a +1 vote.

    EM (trunk) has a java version, Rack seems to install OK on JRuby, so I imagine the parser is the only piece not already there. It seems it wouldn't be too much work to port the Mongrel java parser.

    I've started playing with this today, but MacPorts has Ragel 6.0, which has breaking changes from older versions, so the *.rl files from Mongrel don't work.

  • macournoyer

    macournoyer February 18th, 2008 @ 10:42 PM

    • Milestone changed from 1.0 to Future

    I''m using Ragel 5.24, which I installed from source.

    This is clearly doable and since the parser doesn't change that much.

    But I wonder how EM performs on jruby. Anyone did some benchmarks?

  • alan

    alan February 22nd, 2008 @ 07:21 PM

    +1 ... considering the newest jruby smokes and has good gem compatibility at the moment. It seems ruby 1.9 is a ways off from real world usage, and many poor development souls stuck at companies, locked into using many jars can get the best of both worlds for internal / externals, while avoiding dirty, dirty java.

  • Kevin Williams

    Kevin Williams February 24th, 2008 @ 09:41 AM

    we need EM to release for jruby before we can do anything.

  • macournoyer

    macournoyer February 25th, 2008 @ 05:00 PM

    • Assigned user set to “Kevin Williams”
    • Milestone changed from Future to 1.0
    • State changed from “hold” to “open”
  • macournoyer

    macournoyer July 1st, 2008 @ 09:49 AM

    • Tag set to java, jruby, platform
    • Milestone changed from 1.0 to Waiting for EM

    I red they are working on it right now

  • Kevin Williams
  • Kevin Williams

    Kevin Williams August 26th, 2008 @ 05:05 PM

    I'm working on a java-based backend for Thin. Not sure how it's going to work out because Thin depends on EM for more than just the backend. If we can divorce Thin from EM and constrain EM to backend code, then Thin on JRuby might really rock.

  • macournoyer

    macournoyer August 27th, 2008 @ 01:29 PM

    Aman sent me this:

    fyi, i got the java reactor working


    ran some of my EM libraries through it and it seems to work without modifications or problems



    @kevin: Thin should not depend on EM anymore, only Backends::Base does depend on it. thin-turbo is a non-EM backend and is works fine.

  • Kevin Williams

    Kevin Williams August 27th, 2008 @ 01:40 PM

    lib/thin.rb requires EM, and lib/thin/connection.rb has the Connection class extending EventMachine::Connection. Am I not looking at the right branch or something? I admit I haven't tried running Thin on JRuby without EM installed, but I didn't think I could yet. What am I missing?

  • macournoyer

    macournoyer August 28th, 2008 @ 12:03 PM

    ah right, we can fix that by require all things EM in the Backends::Base, so it it's not loaded EM will not be required.

    Hm, but we'll need to tweak the gem to require EM gem only on non-jruby installation.

    Any better way to make EM optional?

  • Kevin Williams

    Kevin Williams August 28th, 2008 @ 12:14 PM

    Perhaps have a safe alternate backend based on webrick or mongrel? The backend selection code could try to load the EM gem and choose a different backend if not found.

    That would probably mean creating an explicit EM backend, rather that putting EM stuff in Backends::Base.

  • Piotr Gęga (pietia)

    Piotr Gęga (pietia) December 22nd, 2008 @ 03:30 PM


    How is going work with jruby support ? I saw java version of EM.

  • Kevin Williams

    Kevin Williams December 22nd, 2008 @ 04:02 PM

    EM for JRuby isn't formally released, so I haven't tried to do anything yet. I'm continuing to working on getting something based on Mina to work. Almost got it now, just trying to figure out Rack and plugging the two together.

  • Piotr Gęga (pietia)

    Piotr Gęga (pietia) December 22nd, 2008 @ 04:27 PM

    Which version of Mine? Is your code available via net?

  • Kevin Williams

    Kevin Williams December 22nd, 2008 @ 04:28 PM

    The latest version of Mina - no, I haven't released it yet.

  • Aman Gupta

    Aman Gupta April 4th, 2009 @ 11:51 PM

    EM is officially available for jruby via rubyforge, simply: jgem install eventmachine

  • Kevin Williams

    Kevin Williams April 6th, 2009 @ 10:07 AM

    • Milestone changed from Waiting for EM to Future

    Thanks for the update Aman, it did install into my JRuby 1.2.0 install on my laptop. Unfortunately, http://rubyeventmachine.com/wiki... claims it is not officially released yet.

    I'll start working on it now. The first thing I have to do is get the Mongrel parser for Java into Thin and updated with the equivalent code for the ext/thin_parser/thin.c features. This is not familiar ground for me, so it might take a while.

  • Rodrigo Rosenfeld Rosas

    Rodrigo Rosenfeld Rosas July 25th, 2010 @ 08:19 AM

    • Milestone order changed from “0” to “0”

    I'm a bit late, but +1.

    Glassfish is not currently working with newer Oracle JDK and last JRuby on Rails 3 beta 4. There is a problem loading RubySocket.

    Packing the application with warbler also is problematic in Rails 3 beta 4 with threadsafe enabled. I deployed a very basic application packaged as war in a Tomcat container and it hangs after trying concurrent connections (ab -n 2 -c 2

    I was trying to do some benchmark tests but I'm unable to currently run Rails 3 beta 4 on JRuby with threadsafe enabled. Currently my only option is Webrick! :)

    If Thin supported JRuby it would be awesome.

  • Carlos OKieffe
  • Ben

    Ben January 4th, 2012 @ 06:47 PM

    +1 +1 +1 on this. I dont see any commits on the jruby branch since may of '09 - is this no longer happening?

  • Kevin Williams

    Kevin Williams January 13th, 2012 @ 01:42 PM

    I've been dabbling with my Mina (now Netty) based server for years now. I rarely have time to work on it, and when I do, it never works quite right.

    Something very close to what I've been trying to build is https://github.com/matadon/mizuno which uses Jetty. Mizuno seems to work, which is more than I can say for my server. :)

    Now that EventMachine does work on JRuby, perhaps very little is needed to get Thin to work, although the http-parser extension might be a problem. I'd be surprised if it were faster than something more native to Java based on Netty or Jetty, though.

    I don't code in Ruby anymore, and I'm worried about the future of Java in general, so of anyone would like to take this over I'll be happy to hand over responsibility.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.