Friday September 14, 2007
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.
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
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
JRUBY_HOME\bin\_jrubyvars.bat"
and replacefor /r "%JRUBY_HOME%\lib" %%i in (*.jar) do @call "%~dp0_jrubysetcp"
%%ifor %%i in ("%JRUBY_HOME%\lib"\*.jar) do @call "%~dp0_jrubysetcp" %%iThe input line is too long.
:gotCP
was unexpected at this time.Only on Macintosh: "JRUBY_HOME\bin\glassfish_rails"
script executable permissions need to be set explicitly. This is filed as
bug #1348.
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
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
Start GlassFish for this newly created app using the
following command:
%JRUBY_HOME%\bin\jruby -S glassfish_rails
hello
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:
Sep 13, 2007 1:32:42 PM com.sun.enterprise.v3.services.impl.GrizzlyAdapter
postConstruct
INFO: Listening on port 8080
Sep 13, 2007 1:32:42 PM
com.sun.enterprise.v3.services.impl.DeploymentService postConstruct
INFO: Supported containers : jruby,web,php,phobos
Sep 13, 2007 1:32:43 PM com.sun.grizzly.standalone.StaticResourcesAdapter
<init>
INFO: New Servicing page from: C:\workarea\samples\rails\hello\public
C:/jruby-1.0.1/lib/ruby/gems/1.8/gems/actionmailer-1.3.3/lib/action_mail
er.rb:49 warning: already initialized constant MAX_LINE_LEN
Sep 13, 2007 1:32:51 PM com.sun.enterprise.v3.server.AppServerStartup run
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.
jruby script\generate controller say helloThe output of the command looks like:
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
hello\app\views\say directory, edit "hello.rhtml"
such that it looks like:<h1>Say#hello</h1>
<p>Find me in app/views/say/hello.rhtml</p>
<%= @hello_string %>hello\app\controllers directory, edit "say_controller.rb"
such that it looks like:class SayController < ApplicationController
def hello
@hello_string = "Hello from Controller!"
end
end
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 gem v3
Posted by Arun Gupta in web2.0 | Comments[22]
|
|
|
|
|
Today's Page Hits: 3354
Total # blog entries: 994