The Source for Java Technology Collaboration
User: Password:
Register | Login help    

Search

Online Books:
java.net on MarkMail:


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 released last week - 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 checkout the trunk and build yourself.

Here are few simple steps to get you started:
  1. Download and unzip the distribution.
  2. Install Rails and GlassFish gem:

    ~/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:

    ~/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:

    ~/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. ~/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:

    ~/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 >../../../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:



    After adding couple of entries, the page looks like:



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

    TOTD #33 explains how to build GlassFish v3 workspace. Alternatively nightly or promoted builds can be downloaded as well.

  8. Start the v3 server as:

    ~/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:

    ~/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:

    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:



Rails powered by the GlassFish Application Server explain in detail about the several benefits of using GlassFish for Rails development and deployment. 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: rubyonrails jruby ruby glassfish v3 gem
Related Topics >> Glassfish      
Comments
Comments are listed in date ascending order (oldest first)