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.
- Check out the workspace and build it using the following commands:
mkdir jruby-trunk<br>
cd jruby-trunk<br>
svn co http://svn.codehaus.org/jruby/trunk/jruby<br>
ant
Addjruby-trunk/binto your PATH. - Install the required RubyGems
- 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<br>
Bulk updating Gem source index for: http://gems.rubyforge.org<br>
Successfully installed rails-1.2.3<br>
Successfully installed rake-0.7.3<br>
Successfully installed activesupport-1.4.2<br>
Successfully installed activerecord-1.15.3<br>
Successfully installed actionpack-1.13.3<br>
Successfully installed actionmailer-1.3.3<br>
Successfully installed actionwebservice-1.2.3 - 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<br>
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<br>
Successfully installed cgi_multipart_eof_fix-2.3 - Mongrel cannot be installed as a gem on JRuby yet. So
download Mongrel gem and install it as shown below:
Make sure to invoke the command from the directory where theC:\workspaces\jruby-trunk\bin>jruby -S gem install
mongrel-1.0.1-jruby.gem --no-ri --no-rdoc<br>
Successfully installed mongrel, version 1.0.1<br>
<br>
gem is downloaded. -
mongrel_cluster
does not work with JRuby and
does not work on Windows. So Mongrel<a href="http://ola-bini.blogspot.com/2007/05/announcing-mongreljcluster.html">
mongrel_jcluster</a>
clusters cannot be configured on a Windows machine.
- Install Rails Gem version 1.2.3 using the command:
- Create a new directory
jruby-trunk\samples\railsand
create a new Rails application as shown below:
C:\workspaces\jruby-trunk\samples\rails>..\..\bin\jruby -S rails
hello<br>
create<br>
create app/controllers<br>
create app/helpers<br>
create app/models<br>
...<br>
create log/production.log<br>
create log/development.log<br>
create log/test.log - Change to the newly created directory and start Mongrel as shown
below:
C:\workspaces\jruby-trunk\samples\rails\hello>..\..\..\bin\jruby
script\server<br>
=> Booting Mongrel (use 'script/server webrick' to force WEBrick)<br>
=> Rails application starting on http://0.0.0.0:3000<br>
=> Call with -d to detach<br>
=> Ctrl-C to shutdown server<br>
** Ruby version is not up-to-date; loading cgi_multipart_eof_fix<br>
** Starting Mongrel listening at 0.0.0.0:3000<br>
** Starting Rails with development environment...<br>
** Rails loaded.<br>
** Loading any Rails specific GemPlugins<br>
** Signals ready. TERM => stop. USR2 => restart. INT => stop (no
restart).<br>
** Rails signals registered. HUP => reload (without restart). It might
not work well.<br>
** Mongrel available at 0.0.0.0:3000<br>
** Use CTRL-C to stop.
The application is now available athttp://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.<br>
Exiting<br>
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)<br>
from C:/workspaces/jruby-trunk/lib/ruby/gems/1.8/gems/mongrel-1.0.1-jruby/lib/mongrel.rb:723:in
`run'<br>
from C:/workspaces/jruby-trunk/lib/ruby/gems/1.8/gems/mongrel-1.0.1-jruby/lib/mongrel/configurator.rb:271:in
`initialize'<br>
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
mongrel
windows
jrubyonglassfish
glassfish
netbeans
- Login or register to post comments
- Printer-friendly version
- arungupta's blog
- 1184 reads





