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

Pramod and I presented on 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 ?

    The 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 ?

    It's 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
    Then 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:

    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 ?

    Method 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.

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

    Install NetBeans Plugin Portal Update Center first and then install 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 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 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 RFE.
  9. What are the plans for JRuby based debugger in NB ?

    The 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 yet), so it's not practical for debugging large apps like Rails - but it's fine for smaller Ruby script> etc. With C Ruby it's blazingly fast.

    Work is underway to make the fast hooks work with JRuby as well and it's 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 here.
  11. Can GlassFish support multiple Rails versions ?

    Yes, JRuby module on GlassFish Update Center allows to create stand-alone or 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 ?

    Every 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:

    And around 1.1 there will be consolidated numbers for all the benchmarks. Performance has improved again since all these sets were published.
  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:

    Read more about how to 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 state of Rubinius support in JRuby ?

    The state of Rubinius (and other Ruby implementations) is described at Also read a more recent update 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 httpd ?

    Yes, the benchmarks are available here.
Thanks to Tor, Sandip, Charles, Nick, Jean-Francois and Jan for helping with the answers. And Pramod to help me with noting the questions.

Technorati: conf glassfish ruby jruby netbeans rubyonrails q&a


>> Are there any benchmarks on the speed of static pages between GlassFish (Grizzly) and Apache ?

If the question is quoted right, the person probably meant Apache Web Server (a.k.a. Apache httpd).... not Apache Tomcat.

Either the question is unclear or the answer is incorrect.


Posted by Clinton Begin on January 08, 2008 at 10:44 AM PST #

The question was indeed meant Apache httpd, I fixed it.


Posted by Arun Gupta on January 08, 2008 at 01:15 PM PST #

Another question:

When creating a war file following your tutorial for the hello/say app it does not generate a web.xml file so my app simply displays a file directory structure when it is accessed after being deployed on glassfish.

I'm using OS X and this may be a bug.

Posted by James Simonsen on January 11, 2008 at 12:57 AM PST #

Yes, this is filed at:

Posted by Arun Gupta on February 01, 2008 at 09:13 AM PST #

Post a Comment:
Comments are closed for this entry.

profile image
Arun Gupta is a technology enthusiast, a passionate runner, author, and a community guy who works for Oracle Corp.

Java EE 7 Samples

Stay Connected


« July 2016