--> « Previous Page

March 5, 2009

TOTD #71: JRuby and GlassFish Integration Test #2: JRuby 1.2.0 RC1 + Rails 2.2.x + GlassFish v3 Prelude

Categories: rails, totd, web2.0

TOTD #70 shows the first integration integration tests that I typically run to ensure that the latest JRuby and GlassFish versions work nicely with each other.  The second test (explained in this blog) ensures that the same application can be deployed using GlassFish v3 Prelude.

GlassFish v3 Prelude allows Rails applications to be deployed natively, i.e. without any packaging.

Lets begin integration test #2.

  1. Download and unzip GlassFish v3 Prelude. Fire up GlassFish v3 Prelude as:

    ~/tools/glassfish/v3/glassfishv3-prelude/glassfish >./bin/asadmin start-domain
    Name of the domain started: [domain1] and
    its location: [/Users/arungupta/tools/glassfish/v3/glassfishv3-prelude/glassfish/domains/domain1].
    Admin port for the domain: [4848].
  2. Add JRUBY_HOME as “jvm-option” using the following command:
    ~/tools/glassfish/v3/glassfishv3-prelude/glassfish >./bin/asadmin create-jvm-options -DJRUBY_HOME=”/Users/arungupta/tools/jruby-1.2.0RC1″
    created 1 option(s)

    Command create-jvm-options executed successfully.

    This tells the GlassFish runtime to pick JRuby and related libraries from the directory specified in JRUBY_HOME.

  3. Deploy the application as:
    ~/tools/jruby-1.2.0RC1/samples/rails >~/tools/glassfish/v3/glassfishv3-prelude/bin/asadmin deploy runner

    Command deploy executed successfully.

  4. The application should now be accessible on “http://localhost:8080/runner/runners”. But instead the logs (located in “domains/domain1/logs/server.log) shows the following exception:
    Caused by: java.lang.NumberFormatException: For input string: “0RC1″
            at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
            at java.lang.Integer.parseInt(Integer.java:456)
            at java.lang.Integer.parseInt(Integer.java:497)
            at com.sun.grizzly.jruby.RailsAdapter$JRubyVersion.<init>(RailsAdapter.java:137)
            at com.sun.grizzly.jruby.RailsAdapter$JRubyVersion.<init>(RailsAdapter.java:131)
            at com.sun.grizzly.jruby.RailsAdapter.<init>(RailsAdapter.java:110)
            at com.sun.grizzly.jruby.RubyRuntime.<init>(RubyRuntime.java:48)
            … 30 more

    This is filed as issue #7235 in GlassFish Issue Tracker.

  5. Lets try with the JRuby trunk.
    1. Check out JRuby trunk and build the workspace as shown below

      ~/workspaces >svn co http://svn.codehaus.org/jruby/trunk/jruby/
      A    jruby/bench
      A    jruby/bench/bench_tak.rb
      A    jruby/bench/bench_struct.rb

      . . .

      A    jruby/.settings/org.eclipse.jdt.core.prefs
      A    jruby/.settings/org.eclipse.jdt.ui.prefs
       U   jruby
      Checked out revision 9347.
      ~/workspaces >cd jruby/
      ~/workspaces/jruby >ant
      Buildfile: build.xml

      init:

      jar:

      . . .

      _update_scm_revision_:
            [jar] Building jar: /Users/arungupta/workspaces/jruby/lib/jruby.jar
            [jar] Warning: selected jar files include a META-INF/INDEX.LIST which will be replaced by a newly generated one.

      BUILD SUCCESSFUL
      Total time: 1 minute 21 seconds

    2. Install Rails
      ~/workspaces/jruby >./bin/jruby gem install rails
      JRuby limited openssl loaded. gem install jruby-openssl for full support.
      http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
      Successfully installed rake-0.8.4
      Successfully installed activesupport-2.2.2
      Successfully installed activerecord-2.2.2
      Successfully installed actionpack-2.2.2
      Successfully installed actionmailer-2.2.2
      Successfully installed activeresource-2.2.2
      Successfully installed rails-2.2.2
      7 gems installed
      Installing ri documentation for rake-0.8.4…
      Installing ri documentation for activesupport-2.2.2…
      Installing ri documentation for activerecord-2.2.2…
      Installing ri documentation for actionpack-2.2.2…
      Installing ri documentation for actionmailer-2.2.2…
      Installing ri documentation for activeresource-2.2.2…
      Installing RDoc documentation for rake-0.8.4…
      Installing RDoc documentation for activesupport-2.2.2…
      Installing RDoc documentation for activerecord-2.2.2…
      Installing RDoc documentation for actionpack-2.2.2…
      Installing RDoc documentation for actionmailer-2.2.2…
      Installing RDoc documentation for activeresource-2.2.2…
  6. Delete the previously added jvm-option as
    ~/tools/glassfish/v3/glassfishv3-prelude/glassfish >./bin/asadmin delete-jvm-options -DJRUBY_HOME=”/Users/arungupta/tools/jruby-1.2.0RC1″
    deleted 1 option(s)

    Command delete-jvm-options executed successfully.

    and add a new jvm-option pointing to the the new JRUBY_HOME as

    ~/tools/glassfish/v3/glassfishv3-prelude/glassfish >./bin/asadmin create-jvm-options -DJRUBY_HOME=”/Users/arungupta/workspaces/jruby”
    created 1 option(s)

    Command create-jvm-options executed successfully.

  7. Deploy th
    e application as:

    ~/tools/jruby-1.2.0RC1/samples/rails >~/tools/glassfish/v3/glassfishv3-prelude/bin/asadmin deploy –force=true runner

    Command deploy executed successfully.

    The “NumberFormatException” as seen above is shown again in this case.

    If the application is deployed correctly then “http://localhost:8080/runner/runners” will show the scaffold page. The final JRuby 1.2 release will not have any text letters in the version and so you’ll be able to deploy a Rails application using JRuby 1.2 (final release) on GlassFish v3 Prelude.

But for now our test #2 has failed.

Subsequent blogs will show the remainder of tests. The current set of tests are available using the tags rubyonrails+glassfish+integrationtest.

Please leave suggestions on other TOTD (Tip Of The Day) that you’d like to see. A complete archive of all tips is available here.

Technorati: totd rubyonrails glassfish v3 jruby gem integrationtest

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

March 4, 2009

FREE GlassFish Bootcamp – Mar 10, 2009, Santa Clara

Categories: general

Would you like to learn how to run your web apps on GlassFish – be they Java EE or Rails or Grails ?
How to manage/monitor them using the powerful web-based console and asadmin CLI ?
How to create SOAP-based or RESTful Web services and host them on GlassFish ?
How to setup GlassFish Clustering/High Availability and enable session-replication for your web apps ?
How to migrate your apps from other application servers to GlassFish ?

The GlassFish team is conducting a free bootcamp in Sun’s Santa Clara campus on Mar 10, 2009. This will be a mix of presentations and hands-on-lab where you’ll gather all the practical knowledge and tips and tricks for your applications. A tentative agenda is:

  • GlassFish Overview (Preso)
  • Management and Monitoring (Preso + Hands On)
  • Web Services: SOAP + REST (Preso + Hands On)
  • Lunch w/ GlassFish Enterpise Team (Preso)
  • Dynamic Langauges and Frameworks (Preso + Hands On)
  • High Availability/Clustering/Load Balancing (Preso + Hands On)
  • Migration to GlassFish (Preso)

The complete details including agenda, venue, and invite are available here.

You’ll also get a chance to engage with the GlassFish team as well.

So bring your laptops and get ready to learn!

And did I  mention free as in “free beer” ? And food and drinks will be served as well :)

Register here!

UPDATE: The camp is sold out. If you are interested in attending a future boot camp, please drop a comment on this blog.

Technorati: conf glassfish bootcamp sun santaclara

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

March 3, 2009

TOTD #70: JRuby and GlassFish Integration Test# 1: JRuby 1.2.0 RC1 + Rails 2.2.x + GlassFish Gem

Categories: glassfish, rails, totd

JRuby 1.2.0 RC1 is out for a while!

I typically run a series of tests to ensure that any publicly released version of JRuby works nicely with GlassFish. The main goal of running these tests is to discover any blocking bugs before users do. This particular set of tests are being run little late as RC1 was released on Feb 24th. But I’ll describe all the steps clearly in the next few blog entries so that you can try them out yourself.

JRuby team runs a whole slew of tests before releasing any bits. Similarly we run a bunch of tests before releasing GlassFish Gem. These tests, as mentioned earlier, are only to ensure that the latest release of JRuby works nicely with the latest bits of GlassFish.

The first basic test is to check if a simple Rails application can be run using the latest GlassFish Gem. The steps are described next.

First, lets create a database user and grant privileges required by our application:

~/tools >sudo mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 30
Server version: 5.1.30 MySQL Community Server (GPL)

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> create user duke@localhost identified by ‘glassfish’;
Query OK, 0 rows affected (0.00 sec)

mysql> grant all on runner_development.* to duke@localhost identified by ’glassfish’;
Query OK, 0 rows affected (0.03 sec)

mysql> grant all on runner_production.* to duke@localhost identified by ’glassfish’;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit;
Bye

The “runner_development” and “runner_production” databases will be created later. And the database are dropped and created fresh for every test run.

Now lets try to create our first Rails application using JRuby and run it using GlassFish gem:

  1. Download and unzip JRuby 1.2.0 RC1.
  2. Install Rails and GlassFish Gem as:
    ~/tools/jruby-1.2.0RC1 >./bin/jruby -S gem install rails glassfish
    JRuby limited openssl loaded. gem install jruby-openssl for full support.
    http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
    Successfully installed activesupport-2.2.2
    Successfully installed activerecord-2.2.2
    Successfully installed actionpack-2.2.2
    Successfully installed actionmailer-2.2.2
    Successfully installed activeresource-2.2.2
    Successfully installed rails-2.2.2
    Successfully installed rack-0.9.1
    Successfully installed glassfish-0.9.2-universal-java
    8 gems installed
    Installing ri documentation for activesupport-2.2.2…
    Installing ri documentation for activerecord-2.2.2…
    Installing ri documentation for actionpack-2.2.2…
    Installing ri documentation for actionmailer-2.2.2…
    Installing ri documentation for activeresource-2.2.2…
    Installing ri documentation for rack-0.9.1…
    Installing ri documentation for glassfish-0.9.2-universal-java…
    Installing RDoc documentation for activesupport-2.2.2…
    Installing RDoc documentation for activerecord-2.2.2…
    Installing RDoc documentation for actionpack-2.2.2…
    Installing RDoc documentation for actionmailer-2.2.2…
    Installing RDoc documentation for activeresource-2.2.2…
    Installing RDoc documentation for rack-0.9.1…
    Installing RDoc documentation for glassfish-0.9.2-universal-java…
  3. Create a new app as:
    ~/tools/jruby-1.2.0RC1/samples/rails >../../bin/jruby -S rails runner -d mysql
    JRuby limited openssl loaded. gem install jruby-openssl for full support.
    http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
          create 
          create  app/controllers
          create  app/helpers
          . . .
          create  log/server.log
          create  log/production.log
          create  log/development.log
          create  log/test.log
  4. Install MySQL JDBC ActiveRecord adapter as:
    ~/tools/jruby-1.2.0RC1/samples/rails >../../bin/jruby -S gem install activerecord-jdbcmysql-adapter
    JRuby limited openssl loaded. gem install jruby-openssl for full support.
    http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
    Successfully installed activerecord-jdbc-adapter-0.9
    Successfully installed jdbc-mysql-5.0.4
    Successfully installed activerecord-jdbcmysql-adapter-0.9
    3 gems installed
    Installing ri documentation for activerecord-jdbc-adapter-0.9…
    Installing ri documentation for jdbc-mysql-5.0.4…
    Installing ri documentation for activerecord-jdbcmysql-adapter-0.9…
    Installing RDoc documentation for activerecord-jdbc-adapter-0.9…
    Installing RDoc documentation for jdbc-mysql-5.0.4…
    Installing RDoc documentation for activerecord-jdbcmysql-adapter-0.9…

    More details on configuring this adapter here.

  5. Create a simple scaffold:
    ~/tools/jruby-1.2.0RC1/samples/rails/runner >../../../bin/jruby script/generate scaffold runner distance:float time: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/
          . . .
          create    test/fixtures/runners.yml
          create    db/migrate
          create    db/migrate/20090226171752_create_runners.rb
  6. Edit “config/database.yml” to use the JDBC adapter and specify database username/password. Change:
    development:
      adapter: mysql
      encoding: utf8
      database: runner_development
      pool: 5
      username: root
    >   password:
      socket: /tmp/mysql.sock

    to

    development:
      adapter: jdbcmysql
      encoding: utf8
      database: runner_development
      pool: 5
      username: duke
      password: glassfish
      socket: /tmp/mysql.sock

    The change is highlighted in bold letters.

  7. Create and migrate the database as:
    ~/tools/jruby-1.2.0RC1/samples/rails/runner >../../../bin/jruby -S rake db:create
    (in /Users/arungupta/tools/jruby-1.2.0RC1/samples/rails/runner)
    ~/tools/jruby-1.2.0RC1/samples/rails/runner >../../../bin/jruby -S rake db:migrate
    (in /Users/arungupta/tools/jruby-1.2.0RC1/samples/rails/runner)
    ==  CreateRunners: migrating ==================================================
    — create_table(:runners)
       -> 0.1330s
       -> 0 rows
    ==  CreateRunners: migrated (0.1340s) =========================================

    The default RAILS_ENV is DEVELOPMENT so there is no need to specify any addtional arguments.

  8. And then run the application as:
    ~/tools/jruby-1.2.0RC1/samples/rails/runner >../../../bin/jruby -S glassfish
    Feb 26, 2009 10:30:10 AM com.sun.enterprise.glassfish.bootstrap.ASMainStatic start
    INFO: Cache not present, will revert to less efficient algorithm
    Feb 26, 2009 10:30:10 AM com.sun.enterprise.glassfish.bootstrap.ASMainStatic findDerbyClient
    INFO: Cannot find javadb client jar file, jdbc driver not available
    Feb 26, 2009 10:30:10 AM APIClassLoaderService createAPIClassLoader
    INFO: APIClassLoader = java.net.URLClassLoader@14a66e3f
    no resource bundle found for version, using default GlassFish version
    Feb 26, 2009 10:30:11 AM AppServerStartup run
    INFO: [Thread[GlassFish Kernel Main Thread,5,main]] started
    Feb 26, 2009 10:30:11 AM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
    INFO: Listening on port 3000
    Feb 26, 2009 10:30:11 AM com.sun.enterprise.v3.admin.adapter.AdminEndpointDecider setGuiContextRoot
    INFO: Admin Console Adapter: context root: /_____admingui
    Feb 26, 2009 10:30:11 AM com.sun.enterprise.v3.admin.adapter.AdminConsoleAdapter setStateMsg
    INFO: The Admin Console Application is not yet installed.
    Feb 26, 2009 10:30:11 AM com.sun.enterprise.v3.admin.adapter.AdminEndpointDecider setGuiContextRoot
    INFO: Admin Console Adapter: context root: /_____admingui
    Feb 26, 2009 10:30:11 AM org.glassfish.scripting.rails.RailsDeployer load
    INFO: Loading application runner at /
    Feb 26, 2009 10:30:11 AM com.sun.grizzly.jruby.RailsAdapter <init>
    INFO: Jruby version is: 1.2.0RC1
    Feb 26, 2009 10:30:11 AM com.sun.grizzly.jruby.rack.RackApplicationChooser detectRails
    INFO: Detected Rails application
    Feb 26, 2009 10:30:11 AM com.sun.grizzly.jruby.rack.RackApplicationChooser detectRails
    INFO: Rails not in thread-safe mode, starting in single-thread mode
    Feb 26, 2009 10:30:11 AM com.sun.grizzly.pool.DynamicPool logDynamicStatus
    INFO: Pool started without dynamic resizing enabled. Pool will not attempt to determine the upper and lower bounds that it should be using, and will stay at 1
    Feb 26, 2009 10:30:16 AM  
    SEVERE: JRuby limited openssl loaded. gem install jruby-openssl for full support.
    http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
    Feb 26, 2009 10:30:18 AM  
    INFO: RAILS_ROOT /Users/arungupta/tools/jruby-1.2.0RC1/samples/rails/runner
    Feb 26, 2009 10:30:18 AM  
    INFO: PUBLIC_ROOT /Users/arungupta/tools/jruby-1.2.0RC1/samples/rails/runner/public
    Feb 26, 2009 10:30:19 AM com.sun.grizzly.pool.DynamicPool$1 run
    INFO: New instance created in 7,074 milliseconds
    Feb 26, 2009 10:30:19 AM com.sun.enterprise.v3.server.AppServerStartup run
    INFO: GlassFish v3  startup time : Static(525ms) startup services(7962ms) total(8487ms)
    Feb 26, 2009 10:30:19 AM com.sun.enterprise.glassfish.bootstrap.ASMainStatic start
    INFO: Started cache creation
    Feb 26, 2009 10:30:20 AM com.sun.enterprise.glassfish.bootstrap.ASMainStatic start
    INFO: Finished cache creation
    Feb 26, 2009 10:30:34 AM sun.reflect.NativeMethodAccessorImpl invoke0
    INFO: 

    After adding few entries, the output at “http://localhost:3000/runners” looks like:

    So we are able to create a trivial Rails application and run it using GlassFish Gem, that passes Test#1.

The subsequent blogs will show the remainder of tests.

Please leave suggestions on other TOTD (Tip Of The Day) that you’d like to see. A complete archive of all tips is available here.

Technorati: totd rubyonrails glassfish v3 jruby gem integrationtest

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot
« Newer Posts

Powered by WordPress
176545 visits from Sep 11, 2009