Arun Gupta, Miles to go ...

Arun Gupta is a technology enthusiast, a passionate runner, and a community guy who works for Sun Microsystems.

http://blogs.sun.com/arungupta/date/20090422 Wednesday April 22, 2009

LOTD #21: Production Deployment Tips for running Rails on GlassFish v2 using Windows


SeaChange Affinity uses Rails and GlassFish as their deployment platform. One of their core developers posted tips based upon their experience so far and they are available at:

Rails on GlassFish v2 using Windows

Here are some of the quotes:

Glassfish can really handle a heavy load

and

handling 400 simultaneous users under a supremely heavy load, the memory was holding great

All previous links in this series are archived at LOTD.

Technorati: lotd glassfish jruby rubyonrails windows

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20090212 Thursday February 12, 2009

TOTD #69: GlassFish High Availability/Clustering using Sun Web Server + Load Balancer Plugin on Windows Vista


TOTD #67 shows how to configure GlassFish High Availability using Apache httpd + mod_jk on Mac OS X. Even though that's a standard and supported configuration, there are several advantages for replacing Apache httpd with Sun Web Server and mod_jk with Load Balancer plugin that comes with GlassFish.

This Tip Of The Day (TOTD) shows how to configure Clustering and Load Balancing using GlassFish v2.1, Sun Web Server, Load Balancer plugin on Windows Vista. This blog is using JDK 6 U7, GlassFish v2.1 (cluster profile), Sun Web Server 7 U4, and Load Balancer plug-in with Sun GlassFish Enterprise Server 2.1 Enterprise Profile (with HADB link).

Lets get started!

  1. Install the required software
    1. Download JDK (if not already installed).
    2. Download and Install GlassFish v2.1. Make sure to configure using "ant -f setup-cluster.xml". This will ensure that the created domain is capable of creating clusters and can perform in-memory session replication for applications deployed on the cluster.
    3. Download and Install Sun Web Server. The process is very simple by unzipping the downloaded bundle, clicking on "setup.exe" and taking all the defaults.
    4. Download GlassFish Enterprise Profile for Load Balancer plugin bits. Start the install by clicking on the downloaded file and select the options as shown below:


    5. Copy the following "loadbalancer.xml" in "https-<host>" (replace <host> with the host name of your machine) directory of Sun Web Server installation directory:

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE loadbalancer PUBLIC "-//Sun Microsystems Inc.//DTD Sun Java
      System Application Server 9.1//EN"
      "file:///C:/Sun/WebServer7/https-LH-KRKZDW6CJE1V/config/sun-loadbalancer_1_2.dtd
      ">

      <loadbalancer>
       <cluster name="cluster1" policy="round-robin" policy-module="">
        <instance name="instance1" enabled="true"
      disable-timeout-in-minutes="60" listeners="http://localhost:38080" weight="100"/>
        <instance name="instance2" enabled="true"
      disable-timeout-in-minutes="60" listeners="http://localhost:38081" weight="100"/>
        <web-module context-root="/clusterjsp"
      disable-timeout-in-minutes="30" enabled="true" error-url=""/>
        <health-checker interval-in-seconds="7" timeout-in-seconds="5" url="/"/>
       </cluster>
       <property name="response-timeout-in-seconds" value="120"/>
       <property name="reload-poll-interval-in-seconds" value="7"/>
       <property name="https-routing" value="false"/>
       <property name="require-monitor-data" value="false"/>
       <property name="active-healthcheck-enabled" value="false"/>
       <property name="number-healthcheck-retries" value="3"/>
       <property name="rewrite-location" value="true"/>
      </loadbalancer>

      The parameters to be changed are highlighted in bold and explained below:
      1. Sun Web Server installation directory
      2. HTTP port of instances created in the cluster. The ports specified are the default ones and can be found by clicking on the instance as shown below:

      3. Context root of the application that will be deployed in the cluster. The Domain Administration Server (DAS) can be configured to populate this file whenever any application is deployed to the cluster.
  2. Create the cluster as explained in TOTD #67. The admin console shows the following screenshot after the cluster is created and all instances are created/started:

     

    and the following for 2 instances:



  3. Deploy "clusterjsp" as explained in TOTD #67. The admin console shows the following screenshot after "clusterjsp" is deployed:


  4. Start Sun Web Server using "startserv.bat" in "https-<host>" directory.
This concludes the installation and configuration steps, now show time!

Accessing "http://localhost/clusterjsp" shows:



The Sun Web Server is running on port 80 and uses "loadbalancer.xml" to serve the request from the configured instances in <loadbalancer> fragment. This particular page is served by "instance1" as indicated in the image. Lets add session data with property name "aaa" and value "111". The value is shown as:



The instance serving the data, "instance1" in this case, and the session data are highlighted.

Now lets stop "instance1" using the admin console and it looks like:



Click on "RELOAD PAGE" and it looks like:



Exactly same session data is served, this time by "instance2".

The sequence above proves that the session data created by the user is preserved even if the instance serving the data goes down. This is possible because of GlassFish High Availability. The session data is served by the "replica partner" where its already copied using in-memory session replication.

The following articles are also useful:
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 glassfish highavailability clustering loadbalancing lbplugin sunwebserver windows vista

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20090114 Wednesday January 14, 2009

TOTD #65: Windows 7 Beta 1 Build 7000 on Virtual Box: NetBeans + Rails + GlassFish + MySQL


Microsoft released Windows 7 Beta 1 - the next major version of Vista, download here. There are tons of improvments mostly centered around making the content easily & intuitively accessible. But hey, Mac OSX already serves that purpose well for quite some time ;-)

But I still want to make sure that our Rails stack (NetBeans, GlassFish, and MySQL) work fine on it. And it very well do, without any issues, as you'll realize at the end of this blog :)

Lets first get started with installing Windows 7 Beta as a Virtual Box image. Few points to note here:

  • Only IE can be used for downloading Windows 7 Beta, FireFox & Safari on Mac do nothing (confirmed). With a growing share of both Mac and Firefox (TODO: add a link), I think this combination needs to be at least included on their testing matrix. There was no clear way to file bugs but sent feedback using "Send Feedback" button that is omnipresent on top-right corner of each window.
  • The 64-bit Windows 7 installer do not work on Virtual Box 2.1 installed on a 64-bit MacBook Pro. So had to download the 32-bit installer instead :( This seems to be a Virtual Box bug so filed #3027.
  • The 32-bit and 64-bit files are named "7000.0.081212-1400_client_en-us_Ultimate-GB1CULFRE_EN_DVD-32bit.iso" and "7000.0.081212-1400_client_en-us_Ultimate-GB1CULXFRE_EN_DVD.iso" respectively. If you noticed the only difference is the letter "X" before "FRE" . This required a deep look to spot the difference and very non-intuitive. Frankly, I had to put the two names above each other to spot the difference ;-)
Here are my Virtual Box VM settings:


Anyway, after that the install process was pretty simple. Anybody who has previous Windows install experience can vouch the installation mostly  goes seamless, as was the case here. The complete installation using screen snapshots is shown here. Some of the snapshots from my install process are shown below:









Ta da ... after multiple boots during installation, the final welcome screen shows up as following:



Even the beta install required an activation key. The key is shown on the screen after the download. A freshly installed Windows 7 Beta shows the following disk properties:



Lets install our Rails stack.

Download JDK 6 U11 (TODO: check with or w/o NetBeans), MySQL 5.1, NetBeans 6.5 (which includes GlassFish v3 Prelude, JRuby 1.1.4, Rails 2.1, and other goodies)! Alternatively, you can also download JDK 6 U11 + NetBeans 6.5 co-bundle here.

Install them in the same order by double-clicking on the downloaded bundle and taking all default values.

First MySQL installation ...



MySQL is automatically started and registered with Windows as a service.

And then NetBeans installation ...



Because of the default access controls setup in Windows 7 (as in Vista as well), NetBeans need to be run as an administrator by right-clicking, selecting "Run as administrator". Screencast #26 shows to develop, run, and debug a Rails application on GlassFish v3 Prelude. Here are some screen snapshots as the steps outlined in that screencast are performed.

Here is a snapshot that shows how a simple Rails application can be created:



Running the Rails application on GlassFish v3 Prelude ...



And now debugging using the NetBeans IDE ...



Overall, I'm happy with the first experience of Windows 7 Beta 1. The install process was smooth and it was nice to see the picture of a fish on the welcome screen. They can even consider swapping it with a glassfish ;-)

TOTD #64 showed how to install OpenSolaris 2008/11 using Virtual Box and run the same stack there. So be it Windows 7 or Open Solaris 2008/11, you can develop, run, and debug your Rails application with pleasure using NetBeans and GlassFish. And of course, Mac OS X :)

What is your primary Operating System for development ?

Do you use any Virtualization software for trying multiple Operating Systems ? Which one ?

Technorati: totd windows windows7 virtualbox netbeans glassfish mysql rubyonrails jruby

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20080207 Thursday February 07, 2008

TOTD #25: Rails application with PostgreSQL database using NetBeans

This blog describes how you can create a Rails application accessing PostgreSQL database using NetBeans 6.

  1. Download and Configure PostgreSQL
    1. Download PostgreSQL from here.
    2. After download and install, open the PostgreSQL command prompt (from the program menu) and initialize the database by giving the following command (in bin directory):

      initdb -D "\users\Arun Gupta\postgresql\data"

      Note, the directory specified in the command does not exist and will be created after the command is executed. The following output is shown:

      The files belonging to this database system will be owned by user "Arun Gupta".
      This user must also own the server process.

      The database cluster will be initialized with locale English_United States.1252.

      fixing permissions on existing directory /users/Arun Gupta/postgresql/data ... ok
      creating subdirectories ... ok
      selecting default max_connections ... 100
      selecting default shared_buffers/max_fsm_pages ... 32MB/204800
      creating configuration files ... ok
      creating template1 database in /users/Arun Gupta/postgresql/data/base/1 ... ok
      initializing pg_authid ... ok
      initializing dependencies ... ok
      creating system views ... ok
      loading system objects' descriptions ... ok
      creating conversions ... ok
      setting privileges on built-in objects ... ok
      creating information schema ... ok
      vacuuming database template1 ... ok
      copying template1 to template0 ... ok
      copying template1 to postgres ... ok

      WARNING: enabling "trust" authentication for local connections
      You can change this by editing pg_hba.conf or using the -A option the
      next time you run initdb.

      Success. You can now start the database server using:

      "postgres" -D "/users/Arun Gupta/postgresql/data"
      or
      "pg_ctl" -D "/users/Arun Gupta/postgresql/data" -l logfile start

      Please note the username shown in the first line of command output ("Arun Gupta" in this case). This will be required later for configuring database.yml.
    3. Start the PostgreSQL by giving the following command:

      "postgres" -D "/users/Arun Gupta/postgresql/data"

      The following output is shown:

      LOG: database system was shut down at 2008-01-10 22:11:01
      LOG: checkpoint record is at 0/4872F8
      LOG: redo record is at 0/4872F8; undo record is at 0/0; shutdown TRUE
      LOG: next transaction ID: 0/593; next OID: 10820
      LOG: next MultiXactId: 1; next MultiXactOffset: 0
      LOG: database system is ready
  2. Create a JRuby-on-Rails project using PostgreSQL
    1. Using NetBeans, create a Rails project. Select PostgreSQL as the database as shown below:

    2. Update the Development database in "database.yml" to match:

      development:
        adapter: postgresql
        host: localhost
        port: 5432
        database: RailsApplication1_Development
        username: Arun Gupta
        password:


      The default port and username are used.
    3. Install a pure-Ruby Postgres database binding by giving the following commands:

      C:\Program Files\NetBeans 6.0\ruby1\jruby-1.0.2\bin>jruby gem install postgres-pr
      Bulk updating Gem source index for: http://gems.rubyforge.org
      Successfully installed postgres-pr-0.4.0


      Adding the gem using "Tools" -> "Ruby Gems" encounters the issue #122593.
  3. Do the migrations
    1. Open PostgreSQL command prompt and create the database by giving the following command (in bin directory):

      createdb RailsApplication1_Development

      Note this is case sensitive. The following output is shown:

      CREATE DATABASE
    2. Create a new model by right-clicking on the project, selecting "Generate", "model" from the list box and giving the name as "wish".
    3. Expand "Database Migrations", "migrate" and open "001_create_wishes.rb". Change "self.up" helper method as shown below:

      def self.up
        create_table :wishes do |t|
          t.column :greeting, :string
        end
        Wish.create :greeting => "Hello PostgreSQL!"
      end


      This instructs the Rails framework to a new table and populate it with three rows upon migration.
    4. Invoke db:migrate by right-clicking on the project, selecting "Run Rake Task", "db" and then "migrate". This creates the appropriate tables and populate the it with three rows as mentioned above.
  4. Add Controller & View
    1. Right-click on project, select "Generate...".
    2. Take the default value in list box, which is "controller". Specify the value of "Name:" as "show" and value of "Views:" as "wishes".
    3. Expand "Controllers" and open "show_controller.rb" and update the "wishes" helper method as shown below:

      def wishes
        @wish = Wish.find(1).greeting;
      end
    4. Expand "Views", "show", "wishes.rhtml" and add the following fragment as the last line:

      <%= @wish %>
  5. Run the project
    1. Open "wishes.rhtml" and hit Shift+F6 (default keystroke to run the file). The output is shown as:


       

Please leave suggestions on other TOTD that you'd like to see. A complete archive is available here.

Technorati: totd netbeans ruby jruby postgresql windows

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20071220 Thursday December 20, 2007

OSX #1: Getting Started with a Mac for a Windows User

MacBook Image I got a new Apple MacBook Pro (Intel Core 2 Duo, 2GB RAM, 160 GB HDD and other good stuff) and excited about that! However I've been a Windows user all along and this is my first interaction with a Mac.

So here are some basic tips/tools to get you started if you are in the same situation:

  • Start with Mac101 - This will get you familiar with Mac, basic terminology, some keyboard hints and other misc stuff.
  • Keyboard mappings between a Windows and Mac keyboard are very different. It would help to print out the mappings and keep them handy. It can take more than a day to get used to the new mappings. Some specific ones are:
    • "Right-click"ing is not intuitive - Enable Two-Finger Click on the Trackpad
    • No Forward Delete key, Mac equivalent is Fn + Delete
    • No dedicated Home, Page Up or Page Down keys, Instead use Fn + Cursor keys
  • Install the following tools
Also read 10 tips for Mac users switching from Windows and a more comprehensive list at Switch to The Mac.

The box came installed with Tiger (Mac OSX 10.4) as opposed to Leopard (Mac OS X 10.5). Leopard Updates are available for $9.95 until Jan 4th, 2007.

Some other striking difference in the terms of UI are:

  • The menus, instead of stacked to each window, are always available at the top.
  • "Windows Control Panel" is available as "System Preferences" on Dock (the toolbar which is, by default, at the bottom of the screen).
  • Minimize/Maximize/Close buttons are to the left instead of to the right.
  • Maximize button only maximizes to the required extent instead of occupying the entire desktop.
  • Important keyboard shortcuts
    • F9 - Shows all open windows
    • F10 - Shows all open windows for the current application (every thing else is greyed out)
    • F11 - Hides all windows and shows the Desktop
    • F12 - Show Dashboard

Here are some other tasks that I tried:

  • iMovie is really cool, I could easily create a movie (with in-built camera) and upload a video directly to youtube. Really good intuitive interface.
  • Create clean HTML pages (like this blog): TextEdit (the default editor) adds redundant markers and viewing HTML source code is not intuitive/easy. So does NeoOffice. Microsoft Front Page is really good at that and I've thoroughly enjoyed editing my blogs using it. So I'm looking for something comparable on Mac. I found this HTML editor shootout  but most of the editors seem to require some manual addition of HTML tags. Googling further, I found KompoZer (based on Nvu) and liking it so far. Part of the reason is that the look-and-feel is quite like FrontPage ;-)

These tips will at least get you started where you can check Email, IM and Web, view your documents, import key settings from Firefox/Thunderbird and unleash the potential of GlassFish and NetBeans. Lots of other tips are available here, here and here. I'll post more as I learn them. Feel free to post your favorite tool/tip/guidance here.

A complete archive will be available here.

Technorati: windows mac apple tools osxtips

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20071109 Friday November 09, 2007

JRuby 1.0.2 released - Improved Windows experience and Rails 1.2.5 support

JRuby 1.0.2 was released last week.

A total of 99 issues were fixed but I'm particularly excited about JRUBY-1347, JRUBY-1350, JRUBY-1401 and JRUBY-1410. These are some issues that I faced (1347 here, 1350 here, 1401 here, 1410 here) on my primary development machine - Windows.

Here is the status report:

  • On Windows only, the latest Rails gem (1.2.5) is now working with stable release of JRuby (1.0.2 as of today).

  • On Windows only, GlassFish v3 gem does not work with JRuby 1.0.2 but works with the JRuby trunk (JRUBY-1549). The gem works correctly on Solaris and Mac.

  • JRuby 1.0.2 bundles will be available on GlassFish Update Center soon.

Now the details.

Here is the command sequence for creating and hosting a trivial Hello World on WEBrick:

  1. Install Rails

    C:\testbed\ruby\jruby-1.0.2>bin\jruby -S gem install rails --include-dependencies --no-ri --no-rdoc
    Bulk updating Gem source index for: http://gems.rubyforge.org
    Successfully installed rails-1.2.5
    Successfully installed activesupport-1.4.4
    Successfully installed activerecord-1.15.5
    Successfully installed actionpack-1.13.5
    Successfully installed actionmailer-1.3.5
    Successfully installed actionwebservice-1.2.5

  2. Create a template application

    C:\workarea\samples\rails>\testbed\ruby\jruby-1.0.2\bin\jruby -S rails hello
     create
    create app/controllers
    create app/helpers
    create app/models
    create app/views/layouts
    create config/environments
    create components
    create db
    create doc
    create lib
    create lib/tasks
    create log
    create public/images
    create public/javascripts
    create public/stylesheets
    create script/performance
    create script/process
    create test/fixtures
    create test/functional
    create test/integration
    create test/mocks/development
    create test/mocks/test
    create test/unit
    create vendor
    create vendor/plugins
    create tmp/sessions
    create tmp/sockets
    create tmp/cache
    create tmp/pids
    create Rakefile
    create README
    create app/controllers/application.rb
    create app/helpers/application_helper.rb
    create test/test_helper.rb
    create config/database.yml
    create config/routes.rb
    create public/.htaccess
    create config/boot.rb
    create config/environment.rb
    create config/environments/production.rb
    create config/environments/development.rb
    create config/environments/test.rb
    create script/about
    create script/breakpointer
    create script/console
    create script/destroy
    create script/generate
    create script/performance/benchmarker
    create script/performance/profiler
    create script/process/reaper
    create script/process/spawner
    create script/process/inspector
    create script/runner
    create script/server
    create script/plugin
    create public/dispatch.rb
    create public/dispatch.cgi
    create public/dispatch.fcgi
    create public/404.html
    create public/500.html
    create public/index.html
    create public/favicon.ico
    create public/robots.txt
    create public/images/rails.png
    create public/javascripts/prototype.js
    create public/javascripts/effects.js
    create public/javascripts/dragdrop.js
    create public/javascripts/controls.js
    create public/javascripts/application.js
    create doc/README_FOR_APP
    create log/server.log
    create log/production.log
    create log/development.log
    create log/test.log

  3. Add a controller

    C:\workarea\samples\rails>cd hello

    C:\workarea\samples\rails\hello>\testbed\ruby\jruby-1.0.2\bin\jruby script\generate controller say hello
    exists app/controllers/
    exists app/helpers/
    create app/views/say
    exists test/functional/
    create app/controllers/say_controller.rb
    create test/functional/say_controller_test.rb
    create app/helpers/say_helper.rb
    create app/views/say/hello.rhtml

  4. Edit Controller

    C:\workarea\samples\rails\hello>vim app\controllers\say_controller.rb

    Add  @hello_string = "Hello from 1.0.2" in hello helper. The updated file looks like:

    class SayController < ApplicationController

      def hello
        @hello_string = "Hello from 1.0.2"
      end
    end

  5. Edit View

    C:\workarea\samples\rails\hello>vim app\views\say\hello.rhtml

    and add <%= @hello_string %> as the last line. The updated file looks like:

    <h1>Say#hello</h1>
    <p>Find me in app/views/say/hello.rhtml</p>
    <%= @hello_string %>

  6. Start WEBrick and view the page http://localhost:3000/say/hello in a browser window:

    C:\workarea\samples\rails\hello>\testbed\ruby\jruby-1.0.2\bin\jruby script\server
    => Booting WEBrick...
    => Rails application started on http://0.0.0.0:3000
    => Ctrl-C to shutdown server; call with --help for options
    [2007-11-07 17:22:01] INFO WEBrick 1.3.1
    [2007-11-07 17:22:01] INFO ruby 1.8.5 (2007-11-01) [java]
    [2007-11-07 17:22:01] INFO WEBrick::HTTPServer#start: pid=11245030 port=3000
    127.0.0.1 - - [07/Nov/2007:17:22:38 PST] "GET /say/hello HTTP/1.1" 200 81
    - -> /say/hello

The GlassFish v3 Gem does not work with JRuby 1.0.2 (JRUBY-1549) on Windows. It works very well on Solaris and Mac. For Windows, you need to use the JRuby trunk (checkout and build):

After you've built the JRuby trunk, you can create a similar new application and run it on GlassFish v3 gem as:

  1. Download and Install the gem

    C:\workspaces\jruby-trunk>bin\jruby -S gem install glassfish-gem-10.0-SNAPSHOT.gem
    Successfully installed GlassFish, version 10.0.0

  2. Start GlassFish v3 and view the page http://localhost:8080/hello/say/hello:

    C:\workarea\samples\rails>\workspaces\jruby-trunk\bin\jruby -S glassfish_rails hello
    Nov 8, 2007 2:39:07 PM com.sun.enterprise.v3.services.impl.GrizzlyAdapter postConstruct
    INFO: Listening on port 8080
    Nov 8, 2007 2:39:08 PM com.sun.enterprise.v3.services.impl.DeploymentService postConstruct
    INFO: Supported containers : php,phobos,jruby,web
    Nov 8, 2007 2:39:08 PM com.sun.grizzly.standalone.StaticResourcesAdapter <init>
    INFO: New Servicing page from: C:\workarea\samples\rails\hello\public
    Nov 8, 2007 2:39:15 PM com.sun.enterprise.v3.server.AppServerStartup run
    INFO: Glassfish v3 started in 7588 ms
    Nov 8, 2007 2:39:27 PM sun.reflect.NativeMethodAccessorImpl invoke0
    INFO:

    Processing SayController#hello (for 127.0.0.1 at 2007-11-08 14:39:27) [GET]

    Nov 8, 2007 2:39:27 PM sun.reflect.NativeMethodAccessorImpl invoke0
    INFO: Session ID: 46e3279ab4f2d776b4d76010cc7b38af

    Nov 8, 2007 2:39:27 PM sun.reflect.NativeMethodAccessorImpl invoke0
    INFO: Parameters: {"action"=>"hello", "controller"=>"say"}

    Nov 8, 2007 2:39:27 PM sun.reflect.NativeMethodAccessorImpl invoke0
    INFO: Rendering say/hello

    Nov 8, 2007 2:39:27 PM sun.reflect.NativeMethodAccessorImpl invoke0
    INFO: Completed in 0.01100 (90 reqs/sec) | Rendering: 0.00900 (81%) | 200 OK [http://localhost/hello/say/hello]

A comprehensive list of JRuby on GlassFish documentation is available here.

Technorati: jrubyonglassfish jruby glassfish windows rubyonrails v3 gem ruby

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20071016 Tuesday October 16, 2007

TOTD #14: How to generate JRuby-on-Rails Controller on Windows (#9893)

The current Rails Gem (version 1.2.5) gives an error when creating a Controller in a JRuby-on-Rails application on Windows. It gives the following error during controller creation as shown below:

C:/testbed/ruby/jruby-1.0.1/lib/ruby/1.8/pathname.rb:420:in `realpath_rec': No such file or directory -C:/testbed/ruby/jruby-1.0.1/samples/rails/hello/C: (Errno::ENOENT)
    from C:/testbed/ruby/jruby-1.0.1/lib/ruby/1.8/pathname.rb:453:in `realpath'
    from C:/testbed/ruby/jruby-1.0.1/lib/ruby/gems/1.8/gems/rails-1.2.4/lib/initializer.rb:543:in `set_root_path!'
    from C:/testbed/ruby/jruby-1.0.1/lib/ruby/gems/1.8/gems/rails-1.2.4/lib/initializer.rb:509:in `initialize'
    from ./script/../config/boot.rb:35:in `new'
    from ./script/../config/boot.rb:35:in `run'
    from ./script/../config/boot.rb:35
    from :1:in `require'
    from :1

and Rails 1.2.4 gives exactly the same error. This is Ticket #9893. This actually happens because of JRUBY-1401.

The workaround is to use Rails 1.2.3. If you have already installed the latest Rails plugin, then you can uninstall it using the command:

C:\testbed\ruby\jruby-1.0.1\bin>gem uninstall rails
Successfully uninstalled rails version 1.2.5
Remove executables and scripts for
'rails' in addition to the gem? [Yn] y
Removing rails

And then install Rails 1.2.3 as:

gem install rails --include-dependencies --version 1.2.3 --no-ri --no-rdoc
Successfully installed rails-1.2.3
Successfully installed activesupport-1.4.2
Successfully installed activerecord-1.15.3
Successfully installed actionpack-1.13.3
Successfully installed actionmailer-1.3.3
Successfully installed actionwebservice-1.2.3

Now create a new application as shown below:

jruby -S rails hello

And then create a controller as:

jruby script\generate controller say hello
exists app/controllers/
exists app/helpers/
create app/views/say
exists test/functional/
create app/controllers/say_controller.rb
create test/functional/say_controller_test.rb
create app/helpers/say_helper.rb
create app/views/say/hello.rhtml

Hope you find it useful and this bug is fixed in the next version of Rails.

Please leave suggestions on other TOTD that you'd like to see. A complete archive is available here.

Technorati: totd rubyonrails jruby windows

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20071012 Friday October 12, 2007

TOTD #13: Setup Mongrel for JRuby-on-Rails applications on Windows

In a previous entry, I posted instructions on how to setup Mongrel cluster for JRuby-on-Rails applications on Unix-based systems. The instructions specified there do not work on Windows-based systems because of the following reasons:

  • JRuby 1.0.1 + (default) Rails Gem (version 1.2.4) does not work on Windows because of JRUBY-1401. An older Rails version (such as 1.2.3) can always be used as described below.
  • JRuby 1.0.1 + (default) Mongrel 1.0.1 does not work on Windows because of JRUBY-1410, JRUBY-1411.

So if you want JRuby-on-Rails applications to deploy on Mongrel on Windows, then the workaround is to checkout the JRuby trunk and use Rails 1.2.3. This blog explains the instructions on how to do that. The Mongrel cluster cannot be configured on JRuby yet though.

As a side note, repeated invocation of "jruby" command will encounter JRUBY-1350. The workaround is to exit out of the current command prompt and execute the commands in a new one.

  1. Check out the workspace and build it using the following commands:

    mkdir jruby-trunk
    cd jruby-trunk
    svn co http://svn.codehaus.org/jruby/trunk/jruby
    ant


    Add jruby-trunk/bin to your PATH.
  2. Install the required RubyGems
    1. Install Rails Gem version 1.2.3 using the command:

      C:\workspaces\jruby-trunk\bin>jruby -J-Xmx384m -S gem install rails --version 1.2.3 --include-dependencies --no-ri --no-rdoc
      Bulk updating Gem source index for: http://gems.rubyforge.org
      Successfully installed rails-1.2.3
      Successfully installed rake-0.7.3
      Successfully installed activesupport-1.4.2
      Successfully installed activerecord-1.15.3
      Successfully installed actionpack-1.13.3
      Successfully installed actionmailer-1.3.3
      Successfully installed actionwebservice-1.2.3
    2. Before installing Mongrel, install the pre-requisite gems as shown below (see discussion here):

      C:\workspaces\jruby-trunk\bin>jruby -S gem install gem_plugin --no-ri --no-rdoc
      Successfully installed gem_plugin-0.2.2


      and another one:

      C:\workspaces\jruby-trunk\bin>jruby -S gem install cgi_multipart_eof_fix --no-ri --no-rdoc
      Successfully installed cgi_multipart_eof_fix-2.3
    3. Mongrel cannot be installed as a gem on JRuby yet. So download Mongrel gem and install it as shown below:

      C:\workspaces\jruby-trunk\bin>jruby -S gem install mongrel-1.0.1-jruby.gem --no-ri --no-rdoc
      Successfully installed mongrel, version 1.0.1

      Make sure to invoke the command from the directory where the gem is downloaded.
    4. mongrel_cluster does not work with JRuby and mongrel_jcluster does not work on Windows. So Mongrel clusters cannot be configured on a Windows machine.

  3. Create a new directory jruby-trunk\samples\rails and create a new Rails application as shown below:

    C:\workspaces\jruby-trunk\samples\rails>..\..\bin\jruby -S rails hello
    create
    create app/controllers
    create app/helpers
    create app/models
    ...
    create log/production.log
    create log/development.log
    create log/test.log
  4. Change to the newly created directory and start Mongrel as shown below:

    C:\workspaces\jruby-trunk\samples\rails\hello>..\..\..\bin\jruby script\server
    => Booting Mongrel (use 'script/server webrick' to force WEBrick)
    => Rails application starting on http://0.0.0.0:3000
    => Call with -d to detach
    => Ctrl-C to shutdown server
    ** Ruby version is not up-to-date; loading cgi_multipart_eof_fix
    ** Starting Mongrel listening at 0.0.0.0:3000
    ** Starting Rails with development environment...
    ** Rails loaded.
    ** Loading any Rails specific GemPlugins
    ** Signals ready. TERM => stop. USR2 => restart. INT => stop (no restart).
    ** Rails signals registered. HUP => reload (without restart). It might not work well.
    ** Mongrel available at 0.0.0.0:3000
    ** Use CTRL-C to stop.


    The application is now available at http://localhost:3000 and shows the default "Welcome Aboard You're riding the Rails!" page. Hit Ctrl-C to stop Mongrel as shown below:

    ** INT signal received.
    Exiting
    C:/workspaces/jruby-trunk/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:452:in `const_missing': Mongrel::StopServer (Mongrel::StopServer)
            from C:/workspaces/jruby-trunk/lib/ruby/gems/1.8/gems/mongrel-1.0.1-jruby/lib/mongrel.rb:723:in `run'
            from C:/workspaces/jruby-trunk/lib/ruby/gems/1.8/gems/mongrel-1.0.1-jruby/lib/mongrel/configurator.rb:271:in `initialize'
    Terminate batch job (Y/N)? y

An alternative to this behemoth configuration and lack of Mongrel cluster on Windows is to create a Web ARchive (WAR) of your JRuby-on-Rails application and deploy on GlassFish. A complete screencast of how this can be achieved using NetBeans IDE is shown here. A comprehensive list of JRuby on GlassFish documentation is available here.

Technorati: totd rubyonrails jruby ruby mongrel windows jrubyonglassfish glassfish netbeans

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20070423 Monday April 23, 2007

Resolved Vista Upgrade Error 80070103

Follow up from here.

After getting bounced around between Microsoft Tech Support and MSDN Tech Support (seem to be separate entities) and collecting almost 5 different toll-free numbers for them, I finally resolved the error with help from a very talented and patient MSDN Tech Support professional.

Basically, the machine had two partitions - one using Windows XP and other Linux. And somehow the Linux partition was coming out as the primary active partition. So every time I was trying to install Vista, whether from within XP or boot from DVD, it was trying to look for an empty space on this partition. And of course it was not able to find any space because this file system is not NTFS. Now when I look at the error message again, it makes sense. But can't the installation process find out that there are multiple partitions, one of them using NTFS, and then provide that information ?

With tech support help, I resolved the issue by deleting and formatting both the partitions. Another way to resolve this was to set Windows XP as the active partition following these instructions.

I almost lost faith in Microsoft Tech Support but this one talented individual helped me restore it.

Technorati: windows Vista XP microsoft

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20070420 Friday April 20, 2007

XP -> Vista Upgrade: Error 80070103

I've been trying to upgrade an Ultra 20/4 GB RAM with Windows XP + SP2 machine to Windows Vista Ultimate and it's just a plain ugly experience. I've installed Vista on two other machines and it was a much better but this one is the other extreme.

I insert the Vista media in the drive and it pops up a window with an option "Install now". I click on install and then it shows the following error message:

It's hard to understand this error message because the primary drive has 91 GB of free disk space and installed using NTFS. Is the error message trying to convey something else ?

Searched on microsoft.com pointed me to this. But this article is only talking about this error code when installing updates, not updating the whole operating system. Anyway, I installed all the latest updates recommended by Windows Update Center. I also disabled my antivirus software as recommended in "What to know before installing Windows" (even though it's a weird requirement) but this error will not go away.

Tried searching if temp directory is somehow assigned smaller space but didn't find anything on that topic. Not sure if that's even possible.

I posted a question to Vista installation newsgroup. The responses there point to a mismatch (1, 2, 3) between default display drivers provided by Microsoft and nVidia. So I uninstalled the default display driver and installed nVidia's display driver. But still the same error message/number. BTW, the machine has Quadro FX 1400 card.

Then called up nVidia Tech Support. It took them few minutes to figure out that I'm "overwriting" my Window XP with Vista even though I began the call with "I'm upgrading my XP to Vista". Anyway, after the person on tech support understood my issue, I was told to format my Windows XP and then tried installing Vista from scratch! Another quote is "This is definitely a Microsoft problem because Vista is not even getting installed" even though I mentioned that all the links are referring about nVidia driver mismatch. Additionally, nVidia.com main website links to Can your computer run Windows Vista ? which test and reports whether a system can run Windows Vista or not. Interestingly, my laptop (which already has Vista) failed this test at Minimum, Recommended and Optimal level. And the machine on which I'm trying to install Vista passes this test at Minimum level but still giving this weird error.

Finally I called up Microsoft Tech Support and they transferred me to MSDN tech support which close at 5:30pm PT on weekdays.

As a result, I'm stuck this weekend waiting for MSDN tech support to open up Monday morning and then will follow up.

Is Windows Vista really ready for prime time for any serious application ?

UPDATE: Submitted a bug here.

Technorati: windows Vista XP nVidia

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20070410 Tuesday April 10, 2007

Vista on an External Display

Last week, I had to give a presentation and my Tecra M5 Vista laptop would not project on the screen. After playing around with the obvious suspects (Fn keys, Toshiba Presentation Button, changing the resolution) the reason was narrowed down to not having the correct display Driver. After I installed nVidia Display Driver, Vista could project on the screen and I gave a preso yesterday using the same laptop.

There was no need to restart Vista.

Technorati: toshiba tecram5 windows vista

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20070402 Monday April 02, 2007

Laptop upgrade to Vista Ultimate

Follow up from previous entry.

I'm doing this on Toshiba Tecra M5 S433.

The document on how to Upgrade to Windows Vista for Toshiba Tecra M5 gave two options of "manual upgrade" and "manual clean installation". I decided to go the clean installation route mainly because it's simpler and cleaner. Here are the 4 steps listed in the document:

  1. Update the computer's BIOS
  2. Download the Toshiba RAID driver (if required)
  3. Install Windows Vista
  4. Download and install Toshiba software components for Windows Vista

The first step was straight forward so I updated the BIOS to Version 3.20. 2nd step was not required. Then I used the Vista DVD to install the media. And voila, it worked! The last step was kind painful as the document lists 23 software components that need to be downloaded and installed. I talked to the technical support and they said everybody needs to individually download each piece individually and then install them. Why can't Toshiba create a package with all the components that can be downloaded and installed easily ?

Anyway, to save some effort for others, I've provided the list of all the software components after searching for a download link for each of the component:

  1. Alps Pointing Device Driver (driver_touchpad_25333A.exe)
  2. Bluetooth Monitor (util_bluetooth_monitor_25351C.exe)
  3. Bluetooth Stack (driver_bluetooth_25503A.exe)
  4. PCIe Mini Card Driver (driver_wifi_intel_25485B.exe)
  5. Intel Calistoga GM Display Driver (?)
  6. nVidia Display Driver (driver_display_nvidia_25409E.exe)
  7. SigmaTel Audio HD Driver (driver_audio_sigmatel_25410B.exe)
  8. Toshiba Fingerprint Utility (util_fingerprint_25535A.exe)
  9. Toshiba Software Modem (driver_modem_25342E.exe)
  10. CD/DVD Drive Acoustic Silencer (util_drive_silencer_25330E.exe)
  11. Config Free (util_config_free_25573A.exe)
  12. TOSHIBA Assist (util_assist_25533A.exe)
  13. TOSHIBA Disc Creator (util_disc_creator_25489B.exe)
  14. TOSHIBA Extended Tiles for Windows Mobility Center (util_extended_tiles_25331C.exe)
  15. Toshiba HDD Protection (util_hdd_protection_25580A.exe)
  16. TOSHIBA IE Favorites Links
  17. TOSHIBA SD Memory Boot Utility (util_sd_memory_boot_25469C.exe)
  18. TOSHIBA SD Memory Utilities (util_sd_memory_25479B.exe)
  19. TOSHIBA Security Assist (util_security_assist_25329B.exe)
  20. Toshiba Software Upgrades (util_software_upgrades_25157C.exe)
  21. TOSHIBA Value Added Package (util_tvap_25459E.exe)
  22. User's Guide - Unattended Installation
  23. Wireless Key Logon (util_wireless_key_logon_25356D.exe)

This was quite a time consuming process since I had to search for exact match of my laptop's model (Tecra M5 S433) and then copy/paste the link etc. Anyway of the entire list, so far I've installed #9 since that allows me to login to my laptop using biometrics and I love that functionality. May be I'll install others later but I'm good for now.

As I mentioned earlier, this entry is indeed from my laptop with Vista Ultimate now. One good thing with Vista installation is that it preserved all my personal data (which is huge directory space) so there was no need for backing up the laptop. Instead it moved Windows, Program Files and Documents and Settings directories to windows.old. This makes using old data really easy.

So overall, not a bad experience but I spent significant part of my Sunday doing this installation. Hopefully this will save some time for you.

Technorati: toshiba tecram5 windows vista

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20070401 Sunday April 01, 2007

Upgrading Toshiba TecraM5 from XP to Vista

I decided to upgrade my Toshiba Tecra M5 laptop with Windows Vista, finally!

The laptop has the logo "Designed for Windows XP, Windows Vista Capable". A laptop equipped with Windows Vista Capable  meets minimum requirements of 512 MB RAM which does not necessarily mean you'll be able to run all your Windows Vista applications. Rather Vista will deliver sub-XP performance. So I'm not sure how this logo needs to be interpreted.

Anyway, I downloaded Vista and started installing and got the error "Windows cannot be installed on this computer with the current system BIOS version. Contact your computer manufacturer for a BIOS update, install the update, and then start Windows installation again. OEM Name: TOSHIBA; OEM Model: TECRA M5; BIOS Version: v1.60 ; BIOS Date: 20060803000000.000000+000".

Even though the laptop is advertised Vista capable but still need a BIOS update. Why ?

pcsupport.toshiba.com where all the BIOS updates can be downloaded was down most of this morning and so no updates could be downloaded. Toshiba Tech Support told me that new drivers are uploaded to the website but I don't understand why the complete website has to be down for that.

I found out about Windows Vista Upgrade Advisor from the recorded message at the Tech Support. So I downloaded that and got the same error "Windows Vista Upgrade Advisor encountered an error while scanning your system. If the problem persist, you can uninstall and reinstall the latest version." I'm using the latest version available on their website so this error message makes no sense.

Finally, pcsupport.toshiba.com is now live and I found instructions on how to Upgrade to Windows Vista for Toshiba Tecra M5. This is exactly what I've been looking for and fortunately this document was posted on 3/28 (3 days ago). I'm going to follow the instructions here and provide an update later today.

I'm hoping my next blog will be from my upgraded Vista laptop but so far the experience has not been very pleasant. Fingers crossed!

Technorati: toshiba tecram5 windows vista

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

Valid HTML! Valid CSS!

This is a personal weblog, I do not speak for my employer.