Announcing GlassFish Gem for Rails
Jerome has been
working on GlassFish gem for
Rails. Read the interesting discussion on
dev@glassfish. This blog announces a technology preview of this gem and
describes the steps to try it out.
-
If you already have JRuby on Rails configured, then skip this step.
Otherwise you need to install JRuby on Rails.- Download and Unzip JRuby 1.0.1 from
here (lets
say JRUBY_HOME). -
In JRUBY_HOME\bin directory, install Rails plugin using the following command:
jruby -S gem install rails -y --no-rdoc
--no-ri
The output of the command looks like:
Bulk updating Gem source index for: http://gems.rubyforge.org<br>
Successfully installed rails-1.2.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
- Download and Unzip JRuby 1.0.1 from
-
Some platform specific changes listed below are required due to bugs in JRuby
1.0.1.-
Only on Windows
- Edit "
JRUBY_HOME\bin\_jrubyvars.bat"
and replacefor /r "%JRUBY_HOME%\lib" %%i in (*.jar) do @call "%~dp0_jrubysetcp"
%%i
withfor %%i in ("%JRUBY_HOME%\lib"\*.jar) do @call "%~dp0_jrubysetcp" %%i
This change is required because "/r" switch causes the entire tree of the
directory to be parsed instead of just including the JARs in JRUBY_HOME/lib
directory. More details
here.
This is filed as bug
#1347. - The value of CLASSPATH environment variable increases exponentially with
each execution of the gem. Then you start seeing the following error in your
command shell:
The input line is too long.<br>
:gotCP<br>
was unexpected at this time.
This is a filed as bug
#1350. A workaround is to start a new shell when you start seeing the
error.
- Edit "
-
Only on Macintosh: "
JRUBY_HOME\bin\glassfish_rails"
script executable permissions need to be set explicitly. This is filed as
bug #1348.
-
Only on Windows
-
Install the GlassFish gem using the command:
c:\Downloads>\jruby-1.0.1\bin\gem install
glassfish-gem-10.0-SNAPSHOT.gem
The output of the command looks like:
Successfully installed GlassFish, version 10.0.0
Notice, you need to invoke this command from the directory where the gem was
downloaded. -
Create a new rails app using the following command:
%JRUBY_HOME%\bin\jruby -S rails hello
The output of the command looks like:
create<br>
create app/controllers<br>
create app/helpers<br>
create app/models<br>
create app/views/layouts<br>
create config/environments<br>
create components<br>
create db<br>
create doc<br>
create lib<br>
create lib/tasks<br>
create log<br>
create public/images<br>
create public/javascripts<br>
create public/stylesheets<br>
create script/performance<br>
create script/process<br>
create test/fixtures<br>
create test/functional<br>
create test/integration<br>
create test/mocks/development<br>
create test/mocks/test<br>
create test/unit<br>
create vendor<br>
create vendor/plugins<br>
create tmp/sessions<br>
create tmp/sockets<br>
create tmp/cache<br>
create tmp/pids<br>
create Rakefile<br>
create README<br>
create app/controllers/application.rb<br>
create app/helpers/application_helper.rb<br>
create test/test_helper.rb<br>
create config/database.yml<br>
create config/routes.rb<br>
create public/.htaccess<br>
create config/boot.rb<br>
create config/environment.rb<br>
create config/environments/production.rb<br>
create config/environments/development.rb<br>
create config/environments/test.rb<br>
create script/about<br>
create script/breakpointer<br>
create script/console<br>
create script/destroy<br>
create script/generate<br>
create script/performance/benchmarker<br>
create script/performance/profiler<br>
create script/process/reaper<br>
create script/process/spawner<br>
create script/process/inspector<br>
create script/runner<br>
create script/server<br>
create script/plugin<br>
create public/dispatch.rb<br>
create public/dispatch.cgi<br>
create public/dispatch.fcgi<br>
create public/404.html<br>
create public/500.html<br>
create public/index.html<br>
create public/favicon.ico<br>
create public/robots.txt<br>
create public/images/rails.png<br>
create public/javascripts/prototype.js<br>
create public/javascripts/effects.js<br>
create public/javascripts/dragdrop.js<br>
create public/javascripts/controls.js<br>
create public/javascripts/application.js<br>
create doc/README_FOR_APP<br>
create log/server.log<br>
create log/production.log<br>
create log/development.log<br>
create log/test.log -
Start GlassFish for this newly created app using the
following command:
%JRUBY_HOME%\bin\jruby -S glassfish_rails
hello<br>
You need to invoke the command from outside the application
directory instead of the natural way (script\server start).
This will be fixed in the future builds. The output of the command looks
like:
<br>
Sep 13, 2007 1:32:42 PM com.sun.enterprise.v3.services.impl.GrizzlyAdapter
postConstruct<br>
INFO: Listening on port 8080<br>
Sep 13, 2007 1:32:42 PM
com.sun.enterprise.v3.services.impl.DeploymentService postConstruct<br>
INFO: Supported containers : jruby,web,php,phobos<br>
Sep 13, 2007 1:32:43 PM com.sun.grizzly.standalone.StaticResourcesAdapter
<init><br>
INFO: New Servicing page from: C:\workarea\samples\rails\hello\public<br>
C:/jruby-1.0.1/lib/ruby/gems/1.8/gems/actionmailer-1.3.3/lib/action_mail<br>
er.rb:49 warning: already initialized constant MAX_LINE_LEN<br>
Sep 13, 2007 1:32:51 PM com.sun.enterprise.v3.server.AppServerStartup run<br>
INFO: Glassfish v3 started in 8996 ms -
Now you can view the default GlassFish web page at "
http://localhost:8080".
This verifies the basic installation of the GlassFish gem. Lets
add a simple controller to our application.
-
Add a controller to the application by changing to the directory
"hello" and giving the command:
jruby script\generate controller say helloThe output of the
command looks like:exists app/controllers/<br>
exists app/helpers/<br>
create app/views/say<br>
exists test/functional/<br>
create app/controllers/say_controller.rb<br>
create test/functional/say_controller_test.rb<br>
create app/helpers/say_helper.rb<br>
create app/views/say/hello.rhtml - In
hello\app\views\saydirectory, edit "hello.rhtml"
such that it looks like:
<h1>Say#hello</h1><br>
<p>Find me in app/views/say/hello.rhtml</p><br>
<%= @hello_string %> - In
hello\app\controllersdirectory, edit "say_controller.rb"
such that it looks like:class SayController < ApplicationController<br>
def hello<br>
@hello_string = "Hello from Controller!"<br>
end<br>
end - The page is now accessible at "
http://localhost:8080/hello/say/hello".
This is hosted using GlassFish. Of course, the same application can be
deployed on WEBrick by giving the command:
jruby script\server webrick start
Try your applications on GlasFish gem and let us know by leaving a comment on
this blog or sending an email to
users@glassfish or posting to
GlassFish forum.
You can also download GlassFish V3 standalone builds from
here.
The instructions to deploy a Rails application on GlassFish V3 are available
here
and on V2
here.
Technorati:
jruby
ruby
rubyonrails
glassfish
jrubyonglassfish
rubygem
- Login or register to post comments
- Printer-friendly version
- arungupta's blog
- 2529 reads





