Rails and JRuby

Has anyone attempted to run Rails inside of JRuby?

Is that even possible?

Aside from the performance implications, is it a bad idea?

I’m thinking that it might be useful in very rare cases where a
Ruby/Rails - equivalent of a Java solution may not exist yet.

Any thoughts?

Wes

JRuby isn’t a complete Ruby implementation. It won’t work. Apart from
other things using c libraries is not possible.

It’s better to use http://raa.ruby-lang.org/project/rjb/ as a bridge if
you need to use java whiting Ruby.

On 3/21/06, Wes G. [email protected] wrote:

Has anyone attempted to run Rails inside of JRuby?

Yes, it’s currently being worked on by the JRuby maintainers. Jump over
to
the JRuby lists at http://sourceforge.net/mail/?group_id=35413 for
details.
See also recent posts at http://headius.blogspot.com.

Is that even possible?

Not yet, but the plan is to have something to demo by JavaOne this year.

Aside from the performance implications, is it a bad idea?

I personally don’t think so – on the contrary, a solid implementation
of
Ruby on the JVM would do wonders for Ruby adoption across the huge
installed
base of Java and JVMs. For people accustomed to Java-based webapp
deployments (like me), the idea of running Rails in a Java environment
is
staggering and liberating.

Cheers,
/Nick

Nick S. wrote:

installed base of Java and JVMs. For people accustomed to Java-based
webapp deployments (like me), the idea of running Rails in a Java
environment is staggering and liberating.

Yeah, so I can have my servlet container… waaaaaa!

b

Nick S. wrote:

environment is staggering and liberating.
+1

Justin

Thank you Nick for catching this…I need to start filtering to catch
“JRuby” emails on the Rails list too :slight_smile:

We are working feverishly right now to get Rails working on JRuby by
mid-may, for our JavaOne presentation. I can give a brief status update
here:

What works:

  • script/generate runs, with all the base generators in 1.0. I have not
    done
    a comparison, but it appears to be generating correct code and
    configuration. Considering that generate loads up a substantial portion
    of
    Rails, we’re pretty happy that this runs successfully now.
  • some other scripts in /script run, but we have not done a lot of
    additional testing

What doesn’t work:

  • Actually handling a rails request (i.e. through dispatch.cgi) gets
    pretty
    far, but it’s still bombing out due to interpreter issues or missing
    functionality in JRuby. We believe that we’re pretty close, however.

How it will work:

We will probably create a “CGI Servlet” that primes JRuby’s environment
such
that Rails can run out-of-the-box. This should allow anyone to take a
typical Rails app and a given Rails release, JAR them up in an
appropriate
way, and deploy them to your application server of choice. Our emphasis
is
to first make Rails run exactly as it does today, without requiring any
unnecessary modification or special configuration (following the Rails
mentality).

Eventually we would also like to provide seamless support for Rails to
use
J2EE services as though they were Rails equivalents. For example
ActiveRecord adapters to JDBC, remote services in EJBs or Web Service
mapped
appropriately into the Rails world, JTA transaction management,
clustering,
failover, the ability to use JSPs for Rails presentation (such that
existing
apps with extensive existing UIs could be “half-ported” to Rails right
away), and so on. Anything you do in J2EE could be mapped into its much
more
consumable Rails equivalent.

We’re very excited about the possibilities of JRuby on Rails, and we
hope it
will help make Rails a viable option for all those Java-only shops out
there.

The “missing” features have ranged from bugs in the interpreter (for
example, classes not being created with the correct nesting or scope) to
Java’s inability (pre-1.5) to access environment variables (which makes
running a JRuby on Rails “test CGI” impossible). We’re adding everything
that’s missing right now, with a run, debug, fix cycle. Most of the
recent
issues have been minor things missing from JRuby’s core Ruby libraries,
which are usually easy to add.

Charles O Nutter wrote:

What doesn’t work:

  • Actually handling a rails request (i.e. through dispatch.cgi) gets pretty
    far, but it’s still bombing out due to interpreter issues or missing
    functionality in JRuby. We believe that we’re pretty close, however.

Interesting - what’s missing?


David N. Welton

Linux, Open Source Consulting