Skip to main content

GlassFish/JRuby and NetBeans/Ruby Q&A - San Francisco

Posted by arungupta on January 8, 2008 at 6:14 AM PST

and I presented on href="">GlassFish/JRuby
and NetBeans/Ruby
to a partner in San Francisco a few days ago. Here are the questions
asked during the session:

  1. How does
    running the Ruby tests show the green/red status bar ?

    status bar is shown if the test is run as a test, not as a file. (for
    example, using Ctrl+F6, not Shift+F6). Ctrl+F6 can also be invoked on
    the tested class
    and it will run the associated tests for the class. This is the same
    behavior when rake "test" target is invoked.
  2. How fast is
    it to find Ruby arbitrary types in particularly large projects ?

    almost instantaneous and can be achieved using Ctrl+O. It looks at
    project's classes, all the Ruby classes for the built-in libraries, all
    of Ruby-on-Rails, RSpec and all other gems.
  3. Is it
    possible to navigate between Ruby class and tests ?

    Yes, this can be achieved by using Ctrl+Shift+T keyboard shortcut.
  4. Is it
    possible to fix shadowing of variables inside a block of code ?

    Ruby shadows block variables by default.  If you have the
    following code:


    foo = 5

    [1,2,3].each { |foo|  puts foo }

    puts foo


    the block variable "foo" shadows the outer local variable and after
    running this code the local variable foo is equal to 3.

    If you enter this code in NetBeans it will pinpoint this problem
    and offer a quickfix to resolve it as shown below:

    alt="NetBeans 6 Ruby Shadow Variable"
  5. Are comments
    added on a new class seen in the context-sensitive help option ?

    Yes, new methods and comments are all shown in the popup rdocs.
  6. How easy is
    it rename method across main, test and other referring classes ?

    rename, just like variable rename, can be invoked by selecting the
    method name and invoking Ctrl+R or right-clicking and selecting
    "Rename" as shown below.

    alt="Ruby Method rename"
  7. Can Ruby code
    templates be loaded from an external file on the file system ?

    Plugin Portal Update Center first and then install href="">Code
    Template Tools Module. This module allows to import templates
    from an XML-based configuration file.   
  8. Would NB pick
    up dynamic code that is being generated during project execution ?

    Yes and No.  This problem cannot be solved in general as is an
    NP hard
    problem and reduces to the href="">Halting
    problem.  However, since Rails follows
    many conventions, we can solve it for those typical
    conventions. Thus, lots of dynamic classes created by Rails, such as
    active record classes, are included in code completion - see
    for example href="">Ruby
    Screenshot of Week 20. The
    finder  methods included in completion (find_by_price etc.)
    shown in the blog entry are examples of these dynamic things.

    Support for has_many and other similar attributes can be easily added
    as well. Please file an href="">RFE.
  9. What are the
    plans for JRuby based
    debugger in NB ?

    Ruby debugger currently only works well with C
    Ruby.   It
    does work with JRuby as well, but it's extremely slow (because
    there isn't a "fast debugger hooks" implementation available
    so it's not practical for debugging large apps like Rails -
    it's fine for smaller Ruby script> etc. With C Ruby it's

    Work is underway to make the fast hooks work with JRuby as well and
    it's href="">available
    with some duct tape.
  10. How can
    concurrency across multiple machines be achieved ?

    GlassFish can be front-ended with a Load Balancer to achieve concurrent
    applications. Read more details href="">here.
  11. Can
    GlassFish support multiple Rails versions ?

    Yes, href="">JRuby
    module on GlassFish Update Center allows to create style="font-style: italic;">stand-alone or style="font-style: italic;">shared WAR. A
    stand-alone WAR is self-contained and has all the libraries, gems
    & plugins required by the application. A shared WAR has only
    application specific libraries and all other classes are loaded from
    the classpath of GlassFish Application Server instance.

    Mutiple stand-alone WARs can be deployed on the same instance of
    GlassFsh. Alternatively, multiple GlassFish instances, each configured
    with a different Rails version, can be configured on one/multiple
    machines. These instances can be front-ended by a Load Balancer.
  12. In the
    GlassFish case, will the threads supporting the Rails instances share
    the variables or
    is it standalone ?

    request would happen inside its own Rails instance, and there would be
    no sharing during requests. The deployment model is largely the same as
    with mongrels, but without the mongrels.
  13. During record
    migration the associated Active Records need
    to be refreshed. How is this done as part
    of the hot deployment cycle ?

    A shim can be written that run the migrations upon deploy of the WAR
    file. There's a precedence for this
    sort of thing, with products like JIRA that do a database scan at
    startup to make sure you're running the correct version of the tables.
    It's not going to be for everybody, but if you have full control of
    your deployment it's a nice convenience.
  14. What
    advantages does JRuby-on-GlassFish offer to smaller enterprises ?

    GlassFish offers several advantages to enterprises:

    • Allows RoR and Java EE applications to
      co-exist on the same container.
    • Simpler/Similar development/deployment model
    • Database connection pooling
    • Hot deployment of WAR (no need to restart the container)

    And then of course, all the advantages of Load Balancing, Clustering,
    High Availability are available for further scalability as well.

  15. What are the
    benchmark numbers on JRuby ?

    Here are some of the pointers:

    around 1.1 there will be consolidated numbers for all the benchmarks.
    Performance has improved again since all these sets were
  16. When
    would 1.8.6 support be introduced in JRuby ?

    There are plans to update stdlib in JRuby 1.1 - that's really all is
    meant by 1.8.5 support, since largely that's all that's changed.
  17. How is load
    balancing configured in GlassFish ?

    A cluster of GlassFish instances can be load-balanced using any of the
    following approaches:

    • href="">Sun
      LB plug-in on Sun Web Server, Apache and IIS
    • href="">Apache
    • href="">F5
    • href="">Sun
      Secure Application Switch

    Read more about how to href="">setup/configure
    load balancer with GlasFish v2.

  18. How does
    GlassFish deal with
    caching of pages ?

    The file cache in Grizzly provides caching where static pages are
    served without talking to the Web server. 
  19. What is the
    of Rubinius support in JRuby ?

    The state of Rubinius (and other Ruby implementations) is described at
    Also read a more recent update href="">here.

    There are no further updates on Rubinius bytecode support since
    Rubinius bytecode seems to be still changing. We've also managed to
    improve normal interpreted performance, so we're happy enough that
    installing a new bytecode engine hasn't been a priority.

    The JRuby team occasionally plays with getting Rubinius's
    implementations of various
    core classes to run in JRuby, and they usually work well but with about
    a 2x performance hit.
  20. Are there any
    benchmarks on the speed of static pages between GlassFish (Grizzly) and
    Apache ?

    Yes, the benchmarks are available href="">here.

Thanks to Tor,
Sandip, href="">Charles, href="">Nick, href="">Jean-Francois
and Jan
for helping with the answers. And href="">Pramod to help
me with noting the questions.

Technorati: href="">conf href="">glassfish
ruby href="">jruby href="">netbeans href="">rubyonrails

Related Topics >>