Skip to main content

JRuby 1.1.3 released - Getting Started with GlassFish

Posted by arungupta on July 21, 2008 at 11:06 AM PDT



JRuby 1.1.3 was href="http://docs.codehaus.org/display/JRUBY/2008/07/19/JRuby+1.1.3+Released">released
last week - href="http://dist.codehaus.org/jruby/jruby-bin-1.1.3.zip">download
here. The highlights are:

  • 82 issues resolved since JRUby 1.1.2
  • RubyGem 1.2 (phew, finally Gem installation is much faster
    again :)
  • Bunch of Compatibility and Performance problems

Going forward, JRuby point releases will be on a 3-4 week frequency.
And you can always href="http://wiki.jruby.org/wiki/Getting_Started#Downloading_Source_and_Building_Yourself">checkout
the trunk and build yourself.



Here are few simple steps to get you started:

  1. href="http://dist.codehaus.org/jruby/jruby-bin-1.1.3.zip">Download
    and unzip the distribution.
  2. Install Rails and href="http://rubyforge.org/projects/glassfishgem/">GlassFish
    gem:


    cellpadding="2" cellspacing="2">
    ~/testbed/jruby-1.1.3
    >./bin/jruby -S
    gem install rails glassfish --no-ri --no-rdoc


    JRuby limited openssl loaded. gem install jruby-openssl for full
    support.

    http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL

    Successfully installed activesupport-2.1.0

    Successfully installed activerecord-2.1.0

    Successfully installed actionpack-2.1.0

    Successfully installed actionmailer-2.1.0

    Successfully installed activeresource-2.1.0

    Successfully installed rails-2.1.0

    Successfully installed glassfish-0.3.1-universal-java

    7 gems installed
  3. Create a new Rails app as:


    cellpadding="2" cellspacing="2">
    ~/testbed/jruby-1.1.3/samples/rails
    >../../bin/jruby
    -S rails helloworld -d mysql
     

          create 

          create 
    app/controllers

          create 
    app/helpers

          create 
    app/models

          create 
    app/views/layouts

          create 
    config/environments

          create 
    config/initializers

          create  db

          create  doc

    . . .

          create 
    log/server.log

          create 
    log/production.log

          create 
    log/development.log

          create 
    log/test.log
  4. Run Rails application on GlassFish gem as:


    cellpadding="2" cellspacing="2">
    ~/testbed/jruby-1.1.3/samples/rails
    >../../bin/jruby
    -S glassfish_rails helloworld


    Jul 21, 2008 8:32:03 AM com.sun.enterprise.glassfish.bootstrap.ASMain
    main

    INFO: Launching GlassFish on HK2 platform

    Jul 21, 2008 8:32:03 AM
    com.sun.enterprise.glassfish.bootstrap.ASMainHK2 findDerbyClient

    INFO: Cannot find javadb client jar file, jdbc driver not available

    Jul 21, 2008 8:32:04 AM
    com.sun.enterprise.v3.services.impl.GrizzlyProxy start

    INFO: Listening on port 3000

    Jul 21, 2008 8:32:04 AM
    com.sun.enterprise.v3.services.impl.GrizzlyEmbeddedHttpConfigurator
    configureSSL

    WARNING: pewebcontainer.all_ssl_protocols_disabled

    Jul 21, 2008 8:32:04 AM
    com.sun.enterprise.v3.services.impl.GrizzlyEmbeddedHttpConfigurator
    configureSSL

    WARNING: pewebcontainer.all_ssl_ciphers_disabled

    Jul 21, 2008 8:32:04 AM
    com.sun.enterprise.v3.services.impl.GrizzlyProxy start

    INFO: Listening on port 3131

    Jul 21, 2008 8:32:04 AM
    com.sun.enterprise.v3.services.impl.GrizzlyProxy start

    INFO: Listening on port 3838

    Jul 21, 2008 8:32:04 AM
    com.sun.enterprise.v3.admin.adapter.AdminConsoleAdapter setContextRoot

    INFO: Admin Console Adapter: context root: /admin

    Jul 21, 2008 8:32:05 AM com.sun.grizzly.jruby.RailsAdapter
    startRubyRuntimePool

    INFO: Starting Rails instances

    Jul 21, 2008 8:32:09 AM 

    SEVERE: JRuby limited openssl loaded. gem install jruby-openssl for
    full support.

    http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL

    Jul 21, 2008 8:32:10 AM com.sun.grizzly.jruby.RubyObjectPool$1 run

    INFO: JRuby and Rails instance instantiation took : 5623ms

    Jul 21, 2008 8:32:10 AM org.glassfish.scripting.rails.RailsDeployer load

    INFO: Loading application helloworld at /

    Jul 21, 2008 8:32:10 AM com.sun.enterprise.v3.server.AppServerStartup
    run

    INFO: Glassfish v3 started in 7046 ms
  5. Create a scaffold as:

  6. cellpadding="2" cellspacing="2">
    ~/testbed/jruby-1.1.3/samples/rails/helloworld
    >../../../bin/jruby
    script/generate scaffold runner distance:float minutes:integer


    JRuby limited openssl loaded. gem install jruby-openssl for full
    support.

    http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL

          exists 
    app/models/

          exists 
    app/controllers/

          exists 
    app/helpers/

          create 
    app/views/runners

          exists 
    app/views/layouts/

          exists 
    test/functional/

          exists 
    test/unit/

          exists 
    public/stylesheets/

          create 
    app/views/runners/index.html.erb

          create 
    app/views/runners/show.html.erb

          create 
    app/views/runners/new.html.erb

          create 
    app/views/runners/edit.html.erb

          create 
    app/views/layouts/runners.html.erb

          create 
    public/stylesheets/scaffold.css

          create 
    app/controllers/runners_controller.rb

          create 
    test/functional/runners_controller_test.rb

          create 
    app/helpers/runners_helper.rb

          
    route  map.resources :runners

      dependency  model

         
    exists    app/models/

         
    exists    test/unit/

         
    exists    test/fixtures/

         
    create    app/models/runner.rb

         
    create    test/unit/runner_test.rb

         
    create    test/fixtures/runners.yml

         
    create    db/migrate

         
    create   
    db/migrate/20080721153737_create_runners.rb
  7. Start MySQL database, create and migrate the database:


    cellpadding="2" cellspacing="2">
    ~/testbed/jruby-1.1.3/samples/rails/helloworld
    >../../../bin/jruby
    -S rake db:create


    (in /Users/arungupta/testbed/jruby-1.1.3/samples/rails/helloworld)

    ~/testbed/jruby-1.1.3/samples/rails/helloworld > style="font-weight: bold;">../../../bin/jruby -S rake
    db:migrate

    (in /Users/arungupta/testbed/jruby-1.1.3/samples/rails/helloworld)

    == 20080721154435 CreateRunners: migrating
    ====================================

    -- create_table(:runners)

       -> 0.0097s

    == 20080721154435 CreateRunners: migrated (0.0104s)
    ===========================



    Now "http://localhost:3000/runners" page is shown as:



    src="http://blogs.sun.com/arungupta/resource/ror/jruby113-v3gem-runners-default.png">



    After adding couple of entries, the page looks like:



    src="http://blogs.sun.com/arungupta/resource/ror/jruby113-v3gem-runners-entries.png">



    Now, let's try to run the same application on GlassFish v3 stand-alone
    build.



    href="http://blogs.sun.com/arungupta/entry/totd_33_building_glassfish_v3">TOTD
    #33 explains how to build GlassFish v3 workspace.
    Alternatively href="http://download.java.net/glassfish/v3/nightly/">nightly
    or promoted
    builds can be downloaded as well.


  8. Start the v3 server as:


    cellpadding="2" cellspacing="2">
    ~/testbed/glassfish/v3/snapshot/glassfish
    >java
    -DJRUBY_HOME=/Users/arungupta/testbed/jruby-1.1.3 -jar
    modules/glassfish-10.0-SNAPSHOT.jar


    Jul 21, 2008 9:40:41 AM com.sun.enterprise.glassfish.bootstrap.ASMain
    main

    INFO: Launching GlassFish on Apache Felix OSGi platform

    Jul 21, 2008 9:40:41 AM
    com.sun.enterprise.glassfish.bootstrap.ASMainOSGi getSharedRepos

    INFO:
    /Users/arungupta/testbed/glassfish/v3/snapshot/glassfish/domains/domain1/lib
    does not exist



    Welcome to Felix.

    =================



    . . .



    INFO: Started bundle org.glassfish.common.container-common [91]

    Jul 21, 2008 9:47:13 AM
    com.sun.enterprise.v3.admin.adapter.AdminConsoleAdapter setContextRoot

    INFO: Admin Console Adapter: context root: /admin

    Jul 21, 2008 9:47:13 AM OSGiModuleImpl loadClass

    INFO: Started bundle org.glassfish.deployment.deployment-common [71]

    Jul 21, 2008 9:47:13 AM com.sun.enterprise.v3.server.AppServerStartup
    run

    INFO: Glassfish v3 started in 1507 ms
  9. Deploy the application as:


    cellpadding="2" cellspacing="2">
    ~/testbed/jruby-1.1.3/samples/rails
    >~/testbed/glassfish/v3/snapshot/glassfish/bin/asadmin
    deploy helloworld




    Command deploy executed successfully.



    and the GlassFish console shows the following output:


    cellpadding="2" cellspacing="2">
    Jul
    21, 2008 9:47:49 AM OSGiModuleImpl loadClass

    INFO: Started bundle org.glassfish.web.war-util [65]

    Jul 21, 2008 9:47:49 AM OSGiModuleImpl loadClass

    INFO: Started bundle org.glassfish.persistence.jpa-connector [25]

    Jul 21, 2008 9:47:49 AM OSGiModuleImpl loadClass

    INFO: Started bundle org.glassfish.scripting.gf-jruby-connector [13]

    Jul 21, 2008 9:47:49 AM OSGiModuleImpl loadClass

    INFO: Started bundle org.glassfish.core.security [22]

    Jul 21, 2008 9:47:49 AM OSGiModuleImpl loadClass

    INFO: Started bundle org.glassfish.web.gf-web-connector [86]

    Jul 21, 2008 9:47:49 AM OSGiModuleImpl loadClass

    INFO: Started bundle org.glassfish.connectors.gf-connectors-connector
    [53]

    Jul 21, 2008 9:47:49 AM com.sun.grizzly.jruby.RailsAdapter
    startRubyRuntimePool

    INFO: Starting Rails instances

    Jul 21, 2008 9:48:01 AM 

    SEVERE: JRuby limited openssl loaded. gem install jruby-openssl for
    full support.

    http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL

    Jul 21, 2008 9:48:02 AM com.sun.grizzly.jruby.RubyObjectPool$1 run

    INFO: JRuby and Rails instance instantiation took : 12852ms

    Jul 21, 2008 9:48:02 AM org.glassfish.scripting.rails.RailsDeployer load

    INFO: Loading application helloworld at /helloworld

    Jul 21, 2008 9:48:02 AM com.sun.enterprise.v3.deployment.DeployCommand
    execute

    INFO: Deployment of helloworld done is 13326 ms


  10. The deployed application at "http://localhost:8080/helloworld/runners"
    looks like:



    src="http://blogs.sun.com/arungupta/resource/ror/jruby113-v3-runners-entries.png">



href="http://developers.sun.com/appserver/reference/techart/rails_gf/">Rails
powered by the GlassFish Application Server explain in detail
about the several benefits of using GlassFish for Rails development and
deployment. href="http://blogs.sun.com/arungupta/tags/stories+rubyonrails">Rails/GlassFish
Deployment Stories gives a good idea of how to structure your
own application.



Are you using GlassFish for development or deployment of Rails ? Drop a
comment on this blog.



Technorati: href="http://technorati.com/tag/rubyonrails">rubyonrails
jruby href="http://technorati.com/tag/ruby">ruby href="http://technorati.com/tag/glassfish">glassfish
v3 href="http://technorati.com/tag/gem">gem

Related Topics >>