Friday November 21, 2008
TOTD #55: How to build GlassFish v3 Gem ?
GlassFish
Gem is a light-weight and robust deployment solution for
Ruby-on-Rails
and Merb
applications. The gem can be easily installed as:
| gem install glassfish |
| svn co
https://svn.dev.java.net/svn/glassfish-scripting/trunk/rails/v3/gem gem cd gem mvn -U clean install |
Posted by Arun Gupta in web2.0 | Comments[2]
|
|
|
|
|
Tuesday November 18, 2008
TOTD #53: Scaffold in Merb using JRuby/GlassFish
GlassFish
Gem 0.9.0 can be used to run Rails and Merb applications.
Support another Rack-based framework Sinatra is coming up in the near
future. This blog shows how to create a scaffold in Merb and run it
using the
GlassFish gem.

| ~/samples/jruby/merb >~/tools/jruby-1.1.5/bin/jruby -S
merb-gen core --orm activerecord hello Generating with core generator: [ADDED] gems [ADDED] merb.thor [ADDED] .gitignore [ADDED] public/.htaccess [ADDED] doc/rdoc/generators/merb_generator.rb [ADDED] doc/rdoc/generators/template/merb/api_grease.js [ADDED] doc/rdoc/generators/template/merb/index.html.erb [ADDED] doc/rdoc/generators/template/merb/merb.css [ADDED] doc/rdoc/generators/template/merb/merb.rb [ADDED] doc/rdoc/generators/template/merb/merb_doc_styles.css [ADDED] doc/rdoc/generators/template/merb/prototype.js [ADDED] public/favicon.ico [ADDED] public/merb.fcgi [ADDED] public/robots.txt [ADDED] public/images/merb.jpg [ADDED] Rakefile [ADDED] app/controllers/application.rb [ADDED] app/controllers/exceptions.rb [ADDED] app/helpers/global_helpers.rb [ADDED] app/views/exceptions/not_acceptable.html.erb [ADDED] app/views/exceptions/not_found.html.erb [ADDED] autotest/discover.rb [ADDED] autotest/merb.rb [ADDED] autotest/merb_rspec.rb [ADDED] config/init.rb [ADDED] config/rack.rb [ADDED] config/router.rb [ADDED] config/environments/development.rb [ADDED] config/environments/production.rb [ADDED] config/environments/rake.rb [ADDED] config/environments/staging.rb [ADDED] config/environments/test.rb [ADDED] public/javascripts/application.js [ADDED] public/stylesheets/master.css [ADDED] spec [ADDED] app/views/layout/application.html.erb |
| ~/samples/jruby/merb/hello >merb-gen resource Runner
distance:float,minutes:integer Loading init file from /Users/arungupta/samples/jruby/merb/hello/config/init.rb Loading /Users/arungupta/samples/jruby/merb/hello/config/environments/development.rb Generating with resource generator: Loading init file from /Users/arungupta/samples/jruby/merb/hello/config/init.rb Loading /Users/arungupta/samples/jruby/merb/hello/config/environments/development.rb Loading init file from /Users/arungupta/samples/jruby/merb/hello/config/init.rb Loading /Users/arungupta/samples/jruby/merb/hello/config/environments/development.rb Loading init file from /Users/arungupta/samples/jruby/merb/hello/config/init.rb Loading /Users/arungupta/samples/jruby/merb/hello/config/environments/development.rb Loading init file from /Users/arungupta/samples/jruby/merb/hello/config/init.rb Loading /Users/arungupta/samples/jruby/merb/hello/config/environments/development.rb [ADDED] spec/models/runner_spec.rb [ADDED] app/models/runner.rb [ADDED] schema/migrations/001_runner_migration.rb [ADDED] spec/requests/runners_spec.rb [ADDED] app/controllers/runners.rb [ADDED] app/views/runners/index.html.erb [ADDED] app/views/runners/show.html.erb [ADDED] app/views/runners/edit.html.erb [ADDED] app/views/runners/new.html.erb [ADDED] app/helpers/runners_helper.rb resources :runners route added to config/router.rb |
| ~/samples/jruby/merb/hello
>rake db:create (in /Users/arungupta/samples/jruby/merb/hello) JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Loading init file from /Users/arungupta/samples/jruby/merb/hello/config/init.rb Loading /Users/arungupta/samples/jruby/merb/hello/config/environments/development.rb Loading init file from /Users/arungupta/samples/jruby/merb/hello/config/init.rb Loading /Users/arungupta/samples/jruby/merb/hello/config/environments/development.rb ~ It took: 0 ~ Loading: Merb::BootLoader::MixinSession ~ It took: 0 ~ Loading: Merb::BootLoader::BeforeAppLoads ~ It took: 0 ~ Loading: Merb::Orms::ActiveRecord::Connect ~ No database.yml file found in /Users/arungupta/samples/jruby/merb/hello/config. ~ A sample file was created called database.yml.sample for you to copy and edit. |
| :development: &defaults :adapter: mysql :database: hello_development :username: root :password: :host: localhost :socket: /tmp/mysql.sock :encoding: utf8 |
| ~/samples/jruby/merb/hello >rake db:create (in /Users/arungupta/samples/jruby/merb/hello) JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Loading init file from /Users/arungupta/samples/jruby/merb/hello/config/init.rb Loading /Users/arungupta/samples/jruby/merb/hello/config/environments/development.rb Loading init file from /Users/arungupta/samples/jruby/merb/hello/config/init.rb Loading /Users/arungupta/samples/jruby/merb/hello/config/environments/development.rb ~ It took: 0 ~ Loading: Merb::BootLoader::MixinSession ~ It took: 0 ~ Loading: Merb::BootLoader::BeforeAppLoads ~ It took: 0 ~ Loading: Merb::Orms::ActiveRecord::Connect ~ Connecting to database... ~ It took: 0 ~ Loading: Merb::BootLoader::LoadClasses ~ It took: 0 ~ Loading: Merb::BootLoader::Router ~ Compiling routes... ~ It took: 0 ~ Loading: Merb::BootLoader::Templates ~ It took: 0 ~ Loading: Merb::BootLoader::MimeTypes ~ It took: 0 ~ Loading: Merb::BootLoader::Cookies ~ It took: 0 ~ Loading: Merb::BootLoader::SetupSession ~ It took: 1 ~ Loading: Merb::BootLoader::SetupStubClasses ~ It took: 0 ~ Loading: Merb::BootLoader::AfterAppLoads ~ It took: 0 ~ Loading: Merb::BootLoader::ChooseAdapter ~ It took: 0 ~ Loading: Merb::BootLoader::RackUpApplication ~ It took: 0 ~ Loading: Merb::BootLoader::ReloadClasses ~ It took: 0 DEPRECATION WARNING: You're using the Ruby-based MySQL library that ships with Rails. This library will be REMOVED FROM RAILS 2.2. Please switch to the offical mysql gem: `gem install mysql` See http://www.rubyonrails.org/deprecation for details. (called from mysql_connection at /Users/arungupta/tools/jruby-1.1.5/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/connection_adapters/mysql_adapter.rb:81) ~ SQL (0.000581) SET NAMES 'utf8' ~ SQL (0.000581) SET SQL_AUTO_IS_NULL=0 ~ SQL (0.000894) CREATE DATABASE `hello_development` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_general_ci` MySQL hello_development database successfully created |
| ~/samples/jruby/merb/hello
>rake db:migrate (in /Users/arungupta/samples/jruby/merb/hello) JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Loading init file from /Users/arungupta/samples/jruby/merb/hello/config/init.rb Loading /Users/arungupta/samples/jruby/merb/hello/config/environments/development.rb Loading init file from /Users/arungupta/samples/jruby/merb/hello/config/init.rb Loading /Users/arungupta/samples/jruby/merb/hello/config/environments/development.rb ~ It took: 0 ~ Loading: Merb::BootLoader::MixinSession ~ It took: 0 ~ Loading: Merb::BootLoader::BeforeAppLoads ~ It took: 0 ~ Loading: Merb::Orms::ActiveRecord::Connect ~ Connecting to database... ~ It took: 0 ~ Loading: Merb::BootLoader::LoadClasses ~ It took: 1 ~ Loading: Merb::BootLoader::Router ~ Compiling routes... ~ It took: 0 ~ Loading: Merb::BootLoader::Templates ~ It took: 0 ~ Loading: Merb::BootLoader::MimeTypes ~ It took: 0 ~ Loading: Merb::BootLoader::Cookies ~ It took: 0 ~ Loading: Merb::BootLoader::SetupSession ~ It took: 0 ~ Loading: Merb::BootLoader::SetupStubClasses ~ It took: 0 ~ Loading: Merb::BootLoader::AfterAppLoads ~ It took: 0 ~ Loading: Merb::BootLoader::ChooseAdapter ~ It took: 0 ~ Loading: Merb::BootLoader::RackUpApplication ~ It took: 0 ~ Loading: Merb::BootLoader::ReloadClasses ~ It took: 0 DEPRECATION WARNING: You're using the Ruby-based MySQL library that ships with Rails. This library will be REMOVED FROM RAILS 2.2. Please switch to the offical mysql gem: `gem install mysql` See http://www.rubyonrails.org/deprecation for details. (called from mysql_connection at /Users/arungupta/tools/jruby-1.1.5/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/connection_adapters/mysql_adapter.rb:81) ~ SQL (0.000769) SET NAMES 'utf8' ~ SQL (0.000610) SET SQL_AUTO_IS_NULL=0 ~ SQL (0.001609) SHOW TABLES ~ SQL (0.003952) CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB ~ SQL (0.054355) CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`) ~ SQL (0.001691) SHOW TABLES ~ SQL (0.001643) SELECT version FROM schema_migrations ~ Migrating to RunnerMigration (1) == 1 RunnerMigration: migrating =============================================== -- create_table(:runners) ~ SQL (0.005301) CREATE TABLE `runners` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `distance` float, `minutes` int(11), `created_at` datetime, `updated_at` datetime) ENGINE=InnoDB -> 0.0107s == 1 RunnerMigration: migrated (0.0114s) ====================================== ~ SQL (0.014063) INSERT INTO schema_migrations (version) VALUES ('1') ~ SQL (0.003585) SHOW TABLES ~ SQL (0.001324) SELECT version FROM schema_migrations ~ SQL (0.001451) SHOW TABLES ~ SQL (0.017054) SHOW FIELDS FROM `runners` ~ SQL (0.018503) describe `runners` ~ SQL (0.009372) SHOW KEYS FROM `runners` |
| require 'config/dependencies.rb' |
| dependency "merb-assets", "1.0" dependency "merb-helpers", "1.0" |
| resources :runners |
| <h1>Runner controller, index
action</h1> <table> <tr> <th>Distance (in miles)</th> <th>Time (in mins)</th> <th colspan="3">Actions</th> </tr> <% @runners.each do |runner| %> <tr> <td><%=h runner.distance %></td> <td><%=h runner.minutes %></td> <td><%= link_to 'Show', resource(runner) %></td> <td><%= link_to 'Edit', resource(runner, :edit) %></td> <td><%= delete_button(runner, "Delete #{runner.distance}") %></td> </tr> <% end %> </table> <%= link_to 'New', resource(:runners, :new) %> |
| <h1>Runners controller, new
action</h1> <%= form_for(@runner, :action => resource(:runners) ) do %> <p> <%= text_field :distance, :label => "Distance (in miles)" %> </p> <p> <%= text_field :minutes, :label => "Time (in mins)" %> </p> <p> <%= submit "Create" %> </p> <% end =%> <%= link_to 'Back', resource(:runners) %> |
| <h1>Runners controller, show
action</h1> <p>Distance (in miles): <%=h @runner.distance %></p> <p>Time (in mins): <%=h @runner.minutes %></p> <%= link_to 'Back', resource(:runners) %> |
| <h1>Runners controller, edit
action</h1> <%= form_for(@runner, :action => resource(@runner)) do %> <p> <%= text_field :distance, :label => "Distance (in miles)" %> </p> <p> <%= text_field :minutes, :label => "Time (in mins)" %> </p> <p> <%= submit "Update" %> </p> <% end =%> <%= link_to 'Show', resource(@runner) %> | <%= link_to 'Back', resource(:runners) %> |





Posted by Arun Gupta in web2.0 | Comments[5]
|
|
|
|
|
Friday November 14, 2008
TOTD #52: Getting Started with Merb using GlassFish Gem
GlassFish
Gem 0.9.0 was recently
released.
It can run any Rack-compatible
framework such as Rails
and Merb.
Support for another Rack-based framework Sinatra will
be released in the near future. The gem is even extensible and
allows to plug any of your favorite Ruby framework using -apptype
switch (more on this in a future blog). This blog shows how to install
the gem and use it for running a Merb application.

| ~/tools/jruby-1.1.5 >gem install glassfish rack JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Successfully installed glassfish-0.9.0-universal-java Successfully installed rack-0.4.0 2 gems installed Installing ri documentation for glassfish-0.9.0-universal-java... Installing ri documentation for rack-0.4.0... Installing RDoc documentation for glassfish-0.9.0-universal-java... Installing RDoc documentation for rack-0.4.0... |
| ~/tools/jruby-1.1.5 >glassfish -h Synopsis -------- glassfish: GlassFish v3 server for rails, merb, sintra applications Usage: ------ glassfish [OPTION] APPLICATION_PATH -h, --help: show help -c, --contextroot PATH: change the context root (default: '/') -p, --port PORT: change server port (default: 3000) -e, --environment ENV: change rails environment (default: development) -n --runtimes NUMBER: Number of JRuby runtimes to crete initially --runtimes-min NUMBER: Minimum JRuby runtimes to crete --runtimes-max NUMBER: Maximum number of JRuby runtimes to crete APPLICATION_PATH (optional): Path to the application to be run (default: current). |
| ~/tools/jruby-1.1.5
>gem install
merb-core merb-more merb_activerecord JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Successfully installed extlib-0.9.8 Successfully installed abstract-1.0.0 Successfully installed erubis-2.6.2 Successfully installed json_pure-1.1.3 Successfully installed rack-0.4.0 Successfully installed mime-types-1.15 Successfully installed thor-0.9.8 Successfully installed merb-core-1.0 Successfully installed ZenTest-3.11.0 Successfully installed RubyInline-3.8.1 Successfully installed sexp_processor-3.0.0 Successfully installed ParseTree-3.0.2 Successfully installed ruby2ruby-1.2.1 Successfully installed merb-action-args-1.0 Successfully installed merb-assets-1.0 Successfully installed merb-slices-1.0 Successfully installed merb-auth-core-1.0 Successfully installed merb-auth-more-1.0 Successfully installed merb-auth-slice-password-1.0 Successfully installed merb-auth-1.0 Successfully installed merb-cache-1.0 Successfully installed merb-exceptions-1.0 Successfully installed highline-1.5.0 Successfully installed diff-lcs-1.1.2 Successfully installed templater-0.4.0 Successfully installed merb-gen-1.0 Successfully installed haml-2.0.4 Successfully installed merb-haml-1.0 Successfully installed merb-helpers-1.0 Successfully installed mailfactory-1.4.0 Successfully installed merb-mailer-1.0 Successfully installed merb-param-protection-1.0 Successfully installed addressable-1.0.4 Successfully installed data_objects-0.9.6 Successfully installed dm-core-0.9.6 Successfully installed dm-migrations-0.9.6 Successfully installed merb_datamapper-1.0 Successfully installed merb-more-1.0 Successfully installed merb_activerecord-0.9.13 39 gems installed Installing ri documentation for json_pure-1.1.3... Installing ri documentation for rack-0.4.0... Installing ri documentation for mime-types-1.15... . . . Installing RDoc documentation for dm-migrations-0.9.6... Installing RDoc documentation for merb_datamapper-1.0... Installing RDoc documentation for merb_activerecord-0.9.13... |
| ~/samples/jruby/merb >merb-gen core hello Generating with core generator: [ADDED] gems [ADDED] merb.thor [ADDED] .gitignore [ADDED] public/.htaccess [ADDED] doc/rdoc/generators/merb_generator.rb [ADDED] doc/rdoc/generators/template/merb/api_grease.js [ADDED] doc/rdoc/generators/template/merb/index.html.erb [ADDED] doc/rdoc/generators/template/merb/merb.css [ADDED] doc/rdoc/generators/template/merb/merb.rb [ADDED] doc/rdoc/generators/template/merb/merb_doc_styles.css [ADDED] doc/rdoc/generators/template/merb/prototype.js [ADDED] public/favicon.ico [ADDED] public/merb.fcgi [ADDED] public/robots.txt [ADDED] public/images/merb.jpg [ADDED] Rakefile [ADDED] app/controllers/application.rb [ADDED] app/controllers/exceptions.rb [ADDED] app/helpers/global_helpers.rb [ADDED] app/views/exceptions/not_acceptable.html.erb [ADDED] app/views/exceptions/not_found.html.erb [ADDED] autotest/discover.rb [ADDED] autotest/merb.rb [ADDED] autotest/merb_rspec.rb [ADDED] config/init.rb [ADDED] config/rack.rb [ADDED] config/router.rb [ADDED] config/environments/development.rb [ADDED] config/environments/production.rb [ADDED] config/environments/rake.rb [ADDED] config/environments/staging.rb [ADDED] config/environments/test.rb [ADDED] public/javascripts/application.js [ADDED] public/stylesheets/master.css [ADDED] spec [ADDED] app/views/layout/application.html.erb |
| ~/samples/jruby/merb/hello >merb-gen controller Runners Loading init file from /Users/arungupta/samples/jruby/merb/jruby-1.1.5/samples/merb/hello/config/init.rb Loading /Users/arungupta/samples/jruby/merb/jruby-1.1.5/samples/merb/hello/config/environments/development.rb Generating with controller generator: Loading init file from /Users/arungupta/samples/jruby/merb/jruby-1.1.5/samples/merb/hello/config/init.rb Loading /Users/arungupta/samples/jruby/merb/jruby-1.1.5/samples/merb/hello/config/environments/development.rb [ADDED] app/controllers/runners.rb [ADDED] app/views/runners/index.html.erb [ADDED] spec/requests/runners_spec.rb [ADDED] app/helpers/runners_helper.rb |
|
def index @message = "Miles to go ..." render end |



Posted by Arun Gupta in web2.0 | Comments[7]
|
|
|
|
|
Monday September 08, 2008
TOTD #44: JDBC Connection Pooling for Rails on GlassFish v3
TOTD
#9 explained how to configure JDBC connection pooling for
Rails application deployed on GlassFish v2. There are several
benefits of using using the JDBC connection pools:
| ~/samples/jruby >~/tools/jruby-1.1.3/bin/jruby -S
rails
jndi_rails2 -d mysql ~/samples/jruby/jndi_rails2 >~/tools/jruby-1.1.3/bin/jruby script/generate scaffold runner miles:float minutes:integer ~/samples/jruby/jndi_rails2 >~/tools/jruby-1.1.3/bin/jruby -S rake db:create ~/samples/jruby/jndi_rails2 >~/tools/jruby-1.1.3/bin/jruby -S rake db:migrate |
| ~/samples/jruby/jndi_rails2 >~/tools/jruby-1.1.3/bin/jruby -S gem install activerecord-jdbcmysql-adapter |
| ~/samples/jruby/jndi_rails2 >sudo cp ~/tools/mysql-connector-java-5.1.6/mysql-connector-java-5.1.6-bin.jar /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/lib/ext |
| ~/tools/glassfish/v3/b23/glassfishv3-prelude/glassfish >java -Xmx512m -DJRUBY_HOME=/Users/arungupta/tools/jruby-1.1.3 -jar modules/glassfish-10.0-SNAPSHOT.jar |
| ~/samples/jruby/jndi_rails2 >~/tools/glassfish/v3/b23/glassfishv3-prelude/glassfish/bin/asadmin create-jdbc-connection-pool --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource --restype javax.sql.DataSource --property "User=duke:Password=duke:URL=jdbc\:mysql\://localhost/jndi_rails2_production" jdbc/jndi_rails2_pool |
| ~/samples/jruby/jndi_rails2 >~/tools/glassfish/v3/b23/glassfishv3-prelude/glassfish/bin/asadmin create-jdbc-resource --connectionpoolid jdbc/jndi_rails2_pool jdbc/jndi_rails2 |
| ~/samples/jruby >~/tools/glassfish/v3/b23/glassfishv3-prelude/glassfish/bin/asadmin ping-connection-pool jdbc/jndi_rails2_pool |
|
development: adapter: jdbc jndi: jdbc/jndi_rails2 driver: com.mysql.jdbc.Driver |
| ~/samples/jruby >~/tools/glassfish/v3/b22/glassfishv3-prelude/glassfish/bin/asadmin deploy jndi_rails2 |
Posted by Arun Gupta in web2.0 | Comments[11]
|
|
|
|
|
Wednesday July 02, 2008
TOTD #37: SQLite3 with Ruby-on-Rails on GlassFish Gem
![]() |
The default database for Rails 2.0.x application is SQLite3. This database is bundled with Mac OSX Leopard and so makes it really easy to get started with Ruby-on-Rails. But it requires couple of additional steps if you are using JRuby. |
| ~/samples/jruby
>~/testbed/jruby-1.1.2/bin/jruby -S rails runner create create app/controllers create app/helpers create app/models create app/views/layouts . . . create log/server.log create log/production.log create log/development.log create log/test.log |
| # SQLite version 3.x # gem install sqlite3-ruby (not necessary on OS X Leopard) development: adapter: sqlite3 database: db/development.sqlite3 timeout: 5000 # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: adapter: sqlite3 database: db/test.sqlite3 timeout: 5000 production: adapter: sqlite3 database: db/production.sqlite3 timeout: 5000 |
| ~/samples/jruby/runner
>~/testbed/jruby-1.1.2/bin/jruby
-S gem install activerecord-jdbcsqlite3-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.8.2 Successfully installed jdbc-sqlite3-3.5.8 Successfully installed activerecord-jdbcsqlite3-adapter-0.8.2 3 gems installed Installing ri documentation for activerecord-jdbc-adapter-0.8.2... Installing ri documentation for jdbc-sqlite3-3.5.8... Installing ri documentation for activerecord-jdbcsqlite3-adapter-0.8.2... Installing RDoc documentation for activerecord-jdbc-adapter-0.8.2... Installing RDoc documentation for jdbc-sqlite3-3.5.8... Installing RDoc documentation for activerecord-jdbcsqlite3-adapter-0.8.2... |
| development: adapter: jdbcsqlite3 database: db/development.sqlite3 timeout: 5000 |
| ~/samples/jruby/runner
>~/testbed/jruby-1.1.2/bin/jruby
script/generate scaffold run distance:float minutes: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/ exists app/helpers/ create app/views/runs exists app/views/layouts/ exists test/functional/ exists test/unit/ exists public/stylesheets/ create app/views/runs/index.html.erb create app/views/runs/show.html.erb create app/views/runs/new.html.erb create app/views/runs/edit.html.erb create app/views/layouts/runs.html.erb create public/stylesheets/scaffold.css create app/controllers/runs_controller.rb create test/functional/runs_controller_test.rb create app/helpers/runs_helper.rb route map.resources :runs dependency model exists app/models/ exists test/unit/ exists test/fixtures/ create app/models/run.rb create test/unit/run_test.rb create test/fixtures/runs.yml create db/migrate create db/migrate/20080630211244_create_runs.rb |
| ~/samples/jruby/runner
>~/testbed/jruby-1.1.2/bin/jruby
-S rake db:migrate (in /Users/arungupta/samples/jruby/runner) == 20080630205502 CreateRuns: migrating ======================================= -- create_table(:runs) -> 0.0410s -> 0 rows == 20080630205502 CreateRuns: migrated (0.0420s) ============================== |
| development: adapter: jdbcsqlite3 database: runner/db/development.sqlite3 timeout: 5000 |
| ~/samples/jruby
>~/testbed/jruby-1.1.2/bin/jruby
-S glassfish_rails runner Jun 30, 2008 1:52:08 PM com.sun.enterprise.glassfish.bootstrap.ASMain main INFO: Launching GlassFish on HK2 platform Jun 30, 2008 1:52:08 PM com.sun.enterprise.glassfish.bootstrap.ASMainHK2 findDerbyClient INFO: Cannot find javadb client jar file, jdbc driver not available Jun 30, 2008 1:52:09 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start INFO: Listening on port 3000 Jun 30, 2008 1:52:09 PM com.sun.enterprise.v3.services.impl.GrizzlyEmbeddedHttpConfigurator configureSSL WARNING: pewebcontainer.all_ssl_protocols_disabled Jun 30, 2008 1:52:09 PM com.sun.enterprise.v3.services.impl.GrizzlyEmbeddedHttpConfigurator configureSSL WARNING: pewebcontainer.all_ssl_ciphers_disabled Jun 30, 2008 1:52:09 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start INFO: Listening on port 3131 Jun 30, 2008 1:52:09 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start INFO: Listening on port 3838 Jun 30, 2008 1:52:09 PM com.sun.enterprise.v3.admin.adapter.AdminConsoleAdapter setContextRoot INFO: Admin Console Adapter: context root: /admin Jun 30, 2008 1:52:09 PM com.sun.grizzly.jruby.RailsAdapter startRubyRuntimePool INFO: Starting Rails instances Jun 30, 2008 1:52:16 PM SEVERE: JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Jun 30, 2008 1:52:17 PM com.sun.grizzly.jruby.RubyObjectPool$1 run INFO: JRuby and Rails instance instantiation took : 7998ms Jun 30, 2008 1:52:17 PM org.glassfish.scripting.rails.RailsDeployer load INFO: Loading application runner at / Jun 30, 2008 1:52:17 PM com.sun.enterprise.v3.server.AppServerStartup run INFO: Glassfish v3 started in 9430 ms |

Please leave suggestions on other TOTD (Tip Of The Day) that you'd like to see. A complete archive is available here.
Posted by Arun Gupta in web2.0 | Comments[5]
|
|
|
|
|
Tuesday July 01, 2008
TOTD# 36: Writing First Test for a Rails Application
I've created a Rails "Hello World" app numerous
times. But I decided to write a simple using the testing
framework provided by Rails. This blog explains my experience of
writing such a test.
| ~/samples/jruby/test
>~/testbed/jruby-1.1.2/bin/jruby
-S rails helloworld
create create app/controllers create app/helpers create app/models create app/views/layouts create config/environments create config/initializers . . . create log/production.log create log/development.log create log/test.log |
| ~/samples/jruby/test/helloworld >~/testbed/jruby-1.1.2/bin/jruby script/generate controller home index |
| JRuby
limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL /Users/arungupta/testbed/jruby-1.1.2/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:278:in `load_missing_constant': uninitialized constant ActiveRecord (NameError) from /Users/arungupta/testbed/jruby-1.1.2/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:467:in `const_missing' from /Users/arungupta/testbed/jruby-1.1.2/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:479:in `const_missing' from /Users/arungupta/samples/jruby/test/helloworld/config/initializers/new_rails_defaults.rb:5:in `/Users/arungupta/samples/jruby/test/helloworld/config/initializers/new_rails_defaults.rb' from /Users/arungupta/samples/jruby/test/helloworld/config/initializers/new_rails_defaults.rb:502:in `load' from /Users/arungupta/testbed/jruby-1.1.2/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:502:in `load' from /Users/arungupta/testbed/jruby-1.1.2/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:354:in `new_constants_in' from /Users/arungupta/testbed/jruby-1.1.2/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:502:in `load' from /Users/arungupta/testbed/jruby-1.1.2/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/initializer.rb:475:in `load_application_initializers' ... 8 levels... from /Users/arungupta/testbed/jruby-1.1.2/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/commands/generate.rb:27:in `require' from /Users/arungupta/testbed/jruby-1.1.2/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' from script/generate:3 |
| if defined?(ActiveRecord) # Include Active Record class name as root for JSON serialized output. ActiveRecord::Base.include_root_in_json = true # Store the full class name (including module namespace) in STI type column. ActiveRecord::Base.store_full_sti_class = true end |
| ~/samples/jruby/test/helloworld
>~/testbed/jruby-1.1.2/bin/jruby
script/generate controller home index JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL exists app/controllers/ exists app/helpers/ create app/views/home exists test/functional/ create app/controllers/home_controller.rb create test/functional/home_controller_test.rb create app/helpers/home_helper.rb create app/views/home/index.html.erb |
| ~/workspaces/glassfish-scripting/rails/v3/src/test/rails
>~/testbed/jruby-1.1.2/bin/jruby
-S glassfish_rails helloworld Jun 27, 2008 2:46:18 PM com.sun.enterprise.glassfish.bootstrap.ASMain main INFO: Launching GlassFish on HK2 platform Jun 27, 2008 2:46:18 PM com.sun.enterprise.glassfish.bootstrap.ASMainHK2 findDerbyClient INFO: Cannot find javadb client jar file, jdbc driver not available Jun 27, 2008 2:46:18 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start INFO: Listening on port 3000 Jun 27, 2008 2:46:18 PM com.sun.enterprise.v3.services.impl.GrizzlyEmbeddedHttpConfigurator configureSSL WARNING: pewebcontainer.all_ssl_protocols_disabled Jun 27, 2008 2:46:18 PM com.sun.enterprise.v3.services.impl.GrizzlyEmbeddedHttpConfigurator configureSSL WARNING: pewebcontainer.all_ssl_ciphers_disabled Jun 27, 2008 2:46:19 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start INFO: Listening on port 3131 Jun 27, 2008 2:46:19 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start INFO: Listening on port 3838 Jun 27, 2008 2:46:19 PM com.sun.enterprise.v3.admin.adapter.AdminConsoleAdapter setContextRoot INFO: Admin Console Adapter: context root: /admin Jun 27, 2008 2:46:19 PM com.sun.grizzly.jruby.RailsAdapter startRubyRuntimePool INFO: Starting Rails instances Jun 27, 2008 2:46:24 PM SEVERE: JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Jun 27, 2008 2:46:24 PM com.sun.grizzly.jruby.RubyObjectPool$1 run INFO: JRuby and Rails instance instantiation took : 5169ms Jun 27, 2008 2:46:24 PM org.glassfish.scripting.rails.RailsDeployer load INFO: Loading application helloworld at / Jun 27, 2008 2:46:24 PM com.sun.enterprise.v3.server.AppServerStartup run INFO: Glassfish v3 started in 6419 ms Jun 27, 2008 2:46:28 PM com.sun.grizzly.jruby.RailsAdapter$Logger log INFO: |
| require 'home_controller' class HomeControllerTest < ActionController::TestCase def test_index get :index assert_response :success end end |
| ~/workspaces/glassfish-scripting/rails/v3/src/test/rails/helloworld
>~/testbed/jruby-1.1.2/bin/jruby
-S rake test (in /Users/arungupta/workspaces/glassfish-scripting/rails/v3/src/test/rails/helloworld) /Users/arungupta/testbed/jruby-1.1.2/bin/jruby -Ilib:test "/Users/arungupta/testbed/jruby-1.1.2/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake/rake_test_loader.rb" /Users/arungupta/testbed/jruby-1.1.2/bin/jruby -Ilib:test "/Users/arungupta/testbed/jruby-1.1.2/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake/rake_test_loader.rb" "test/functional/home_controller_test.rb" JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Loaded suite /Users/arungupta/testbed/jruby-1.1.2/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake/rake_test_loader Started . Finished in 0.308 seconds. 1 tests, 1 assertions, 0 failures, 0 errors /Users/arungupta/testbed/jruby-1.1.2/bin/jruby -Ilib:test "/Users/arungupta/testbed/jruby-1.1.2/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake/rake_test_loader.rb" |
Please leave suggestions on other TOTD (Tip Of The Day) that you'd like to see. A complete archive is available here.
Technorati: rubyonrails jruby ruby glassfish totdPosted by Arun Gupta in web2.0 | Comments[0]
|
|
|
|
|
Monday June 23, 2008
TOTD #35: Rails Database Connection on Solaris
Are you deploying your JRuby-on-Rails applications
on Solaris
(or any variety of Unix) and not able to connect to the database ?
I experienced it last week so thought of sharing the tip here. Luckily
it's really simple.
Here is the default generated "config/database.yml"
| development: adapter: mysql encoding: utf8 database: runner_development username: root password: socket: /tmp/mysql.sock |
| development: adapter: mysql encoding: utf8 database: runner_development username: root password: socket: /tmp/mysql.sock host: 127.0.01 |
Please leave suggestions on other TOTD (Tip Of The Day) that you'd like to see. A complete archive is available here.
Technorati: totd rubyonrails jruby ruby opensolaris mysqlPosted by Arun Gupta in web2.0 | Comments[3]
|
|
|
|
|
Monday April 28, 2008
TOTD #32: Rails Deployment on GlassFish v3 from NetBeans IDE
Rails
powered by the GlassFish Application Server explains all the
benefits of using GlassFish for developing and deploying your Rails
applications. If you are using NetBeans
6.1 builds then you can deploy your Rails application
directly on GlassFish
v3 from within NetBeans
IDE. No longer you need
to have different development and deployment options.
This blog explains how to install a bleeding-edge GlassFish v3 plugin
and use it to deploy your Rails app natively on GlassFish (no WAR or
anything :). Let's get started! Note, this plugin is bleeding edge and
will soon be released on the Beta Update Center.












Please leave suggestions on other TOTD (Tip Of The Day) that you'd like to see. A complete archive is available here.
Technorati: totd glassfish v3 netbeans rubyonrailsPosted by Arun Gupta in web2.0 | Comments[4]
|
|
|
|
|
Wednesday February 20, 2008
TOTD #28: Getting Started with Rails 2.0 Scaffold
Rails
2.0 changes the way Scaffold
works. This blog walks you through the steps to create a simple CRUD
application using Scaffold in Rails 2.0.
jruby -S gem install railscd samples; mkdir rails; cd rails
jruby -S rails books -d mysqlsudo /usr/local/mysql/bin/mysqld_safe --consolecd books
jruby -S rake db:create
db:create:all |
Create all the databases (_Development, _Test, _Production) |
db:drop |
Drops your database |
db:reset |
Drop and Re-create your database, including migrations |
jruby script/generate scaffold book title:string author:string
isbn:string description:text
exists
app/models/
exists
app/controllers/
exists
app/helpers/
create
app/views/books
exists
app/views/layouts/
exists
test/functional/
exists
test/unit/
create
app/views/books/index.html.erb
create
app/views/books/show.html.erb
create
app/views/books/new.html.erb
create
app/views/books/edit.html.erb
create
app/views/layouts/books.html.erb
create
public/stylesheets/scaffold.css
dependency model
exists app/models/
exists test/unit/
exists test/fixtures/
create app/models/book.rb
create test/unit/book_test.rb
create test/fixtures/books.yml
create db/migrate
create db/migrate/001_create_books.rb
create
app/controllers/books_controller.rb
create
test/functional/books_controller_test.rb
create
app/helpers/books_helper.rb
route
map.resources :booksdb/migrate/001_create_books.rb"
migration which looks like:class CreateBooks < ActiveRecord::Migration
def self.up
create_table :books do |t|
t.string :title
t.string :author
t.string :isbn
t.text :description
t.timestamps
end
end
def self.down
drop_table :books
end
endjruby -S rake db:migrate
jruby script/serverhttp://localhost:3000/books"
and looks like:


Posted by Arun Gupta in web2.0 | Comments[5]
|
|
|
|
|
Friday February 15, 2008
TOTD #27: Configurable Multiple Ruby Platforms in NetBeans 6.1 M1
NetBeans 6.1 M1 is now available. Download here!
There are several
features in M1. But the feature I liked the most is storing
multiple Ruby/JRuby runtime configurations in the IDE. In NetBeans 6.0
only one Ruby platform could be configured and stored. So if you have
to change to another Ruby environment then you have to edit the values
in the IDE. 6.1 M1 allows to configure and store multiple Ruby/JRuby
runtimes. Click on "Tools", "Ruby
Platforms" and you are presented with the following window:

I've already added JRuby 1.0.3 as an additional platform. And then you can choose the Ruby/JRuby runtime when creating the Rails application as shown below:

Please leave suggestions on other TOTD that you'd like to see. A complete archive is available here.
Posted by Arun Gupta in web2.0 | Comments[4]
|
|
|
|
|
Wednesday February 13, 2008
TOTD #26: Overriding Database Defaults in Rails 2.0.2
A Rails 2.0.2 application configures SQLite3 database by default. This requires you to have SQLlite3 database running and also have the corresponding database adapter installed. Even this is part of the Leopard (Mac OS 10.5+) development kit but this needs extra configuration on non-Leopard machines.
One of the guiding principles of Rails is Convention-over-Configuration. So there are couple of ways you can override this default:
jruby -S rails -d mysql myappconfig/environment.rb"
and adding the line:config.frameworks -= [ :active_record ]environment.rb"
and remove other frameworks from inside the parentheses.Please leave suggestions on other TOTD that you'd like to see. A complete archive is available here.
Posted by Arun Gupta in web2.0 | Comments[5]
|
|
|
|
|
Wednesday February 06, 2008
TOTD #24: Getting Started with Rails 2.0.x in JRuby 1.0.3 and JRuby 1.1RC1
This TOTD (Tip Of The Day) shows how to install Rails 2.0.x in JRuby
1.0.3 and JRuby 1.1 RC1. Then it describes how a simple Rails
application can be created and deployed using WEBrick.
First, lets deal with installing Rails 2.0.x in JRuby 1.0.3 and JRuby
1.1 RC1.
Step 1: How to install Rails
2.0.x in JRuby 1.0.3 ?
jruby-1.0.3"
directory.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-2.0.2
Successfully installed activesupport-2.0.2
Successfully installed activerecord-2.0.2
Successfully installed actionpack-2.0.2
Successfully installed actionmailer-2.0.2
Successfully installed activeresource-2.0.2Step 2: How to install Rails 2.0.x in JRuby 1.1RC1?
jruby-1.1RC1"
directory.bin/jruby -S gem install rails --no-ri --no-rdoc
Updating metadata for 632 gems from http://gems.rubyforge.org
................................................................................................................
................................................................................................................
................................................................................................................
................................................................................................................
................................................................................................................
........................................................................
complete
Successfully installed activesupport-2.0.2
Successfully installed activerecord-2.0.2
Successfully installed actionpack-2.0.2
Successfully installed actionmailer-2.0.2
Successfully installed activeresource-2.0.2
Successfully installed rails-2.0.2
6 gems installedStep 3: How to create and deploy a trivial Rails app ?
Once Rails is installed in JRuby 1.x, then the steps to develop and deploy a simple application are exactly same and given below:jruby -S rails --database mysql hellocd hello
jruby script/generate controller say hellovi app/controllers/say_controller.rbhello" helper method to look
like:def hello
@hello_string = "Hello from Rail 2.0.2!!"
endvi app/views/say/hello.html.erb<%= @hello_string %>config.frameworks
-= [ :active_record, :action_mailer ]" in "config/environment.rb".
Follow the steps below if you prefer configuring the database:sudo /usr/local/mysql/bin/mysqld_safe --user root
Starting mysqld daemon with databases from /usr/local/mysql/datajruby -S rake db:createjruby script/server
=> Booting WEBrick...
=> Rails application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options
[2008-02-05 23:35:02] INFO WEBrick 1.3.1
[2008-02-05 23:35:02] INFO ruby 1.8.5 (2007-12-15) [java]
[2008-02-05 23:35:02] INFO WEBrick::HTTPServer#start:
pid=13446204 port=3000
http://localhost:3000/say/hello.
Accessing the application shows the following output in console:127.0.0.1 - - [05/Feb/2008:23:35:31 PST] "GET
/say/hello HTTP/1.1" 200 89
- -> /say/hello
127.0.0.1 - - [05/Feb/2008:23:35:32 PST] "GET /say/hello HTTP/1.1" 200
89
- -> /say/hello
127.0.0.1 - - [05/Feb/2008:23:35:32 PST] "GET /say/hello HTTP/1.1" 200
89
- -> /say/hello=> Booting WEBrick...
=> Rails application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options
[2008-02-05 23:37:43] INFO WEBrick 1.3.1
[2008-02-05 23:37:43] INFO ruby 1.8.6 (2008-01-07) [java]
[2008-02-05 23:37:43] INFO WEBrick::HTTPServer#start:
pid=2533 port=3000
127.0.0.1 - - [05/Feb/2008:23:37:51 PST] "GET /say/hello HTTP/1.1" 200
89
- -> /say/helloPlease leave suggestions on other TOTD that you'd like to see. A complete archive is available here.
Posted by Arun Gupta in web2.0 | Comments[4]
|
|
|
|
|
Monday November 19, 2007
TOTD #18: How to Build The GlassFish v3 Gem for JRuby ?
Jerome posted the instructions to build GlassFish v3 Gem for JRuby - very simple and easy. A binary version of Gem is available here.
JRUBY_HOME). Make sure
JRUBY_HOME/bin is in your path.As explained in
Jerome's
entry, you can check out complete GlassFish v3 workspace or just the
Gem code. Here is how you'll check out only the Gem code on a Windows
machine using Tigris Subversion client:

And after the check out is complete, you'll see:

mvn install[INFO] (in
C:/workspaces/glassfish/gem/target/dependency/glassfish)
[WARNING] mkdir -p pkg
[INFO] Successfully built RubyGem
[INFO] Name: GlassFish
[WARNING] mv GlassFish-10.0.0-java.gem pkg/GlassFish-10.0.0-java.gem
[INFO] Version: 10.0.0
[INFO] File: GlassFish-10.0.0-java.gem
[INFO] [install:install]
[INFO] Installing
C:\workspaces\glassfish\gem\target\gem-10.0-SNAPSHOT.jar to C:\Users\Arun
Gupta\.m2\repository\org\glassfish\distributions\gem\10.0-SNAPSHOT\gem-10.0-SNAPSHOT.jar
[INFO] [install:install-file {execution: install-gem}]
[INFO] Installing
C:\workspaces\glassfish\gem\target\dependency\glassfish\pkg\GlassFish-10.0.0-java.gem
to C:\Users\Arun
Gupta\.m2\repository\org\glassfish\distributions\GlassFish-Gem\10.0-SNAPSHOT\GlassFish-Gem-10.0-SNAPSHOT.gem
[INFO]
------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 2 minutes 2 seconds
[INFO] Finished at: Fri Nov 16 17:56:12 PST 2007
[INFO] Final Memory: 11M/20M
[INFO]
------------------------------------------------------------------------
The Gem is available in target\dependency\glassfish\pkg
directory.cd target\dependency\glassfish\pkgC:\testbed\ruby\jruby-1.0.2\bin\jruby -S gem install
GlassFish-10.0.0-java.gem
Successfully installed GlassFish, version 10.0.0And use it!
Please leave suggestions on other TOTD that you'd like to see. A complete archive is available here.
Technorati: totd v3 jruby ruby rubyonrails glassfish gem jrubyonglassfish
Posted by Arun Gupta in Finance | Comments[2]
|
|
|
|
|
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
Posted by Arun Gupta in web2.0 | Comments[2]
|
|
|
|
|
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:
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.
mkdir jruby-trunk
cd jruby-trunk
svn co http://svn.codehaus.org/jruby/trunk/jruby
antjruby-trunk/bin to your PATH.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.3C:\workspaces\jruby-trunk\bin>jruby -S gem install gem_plugin
--no-ri --no-rdoc
Successfully installed gem_plugin-0.2.2C:\workspaces\jruby-trunk\bin>jruby -S gem install
cgi_multipart_eof_fix --no-ri --no-rdoc
Successfully installed cgi_multipart_eof_fix-2.3C:\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.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.
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.logC:\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.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)? yAn 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
Posted by Arun Gupta in web2.0 | Comments[2]
|
|
|
|
|
Today's Page Hits: 2710
Total # blog entries: 1007
| « December 2009 | ||||||
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
| 4 | 5 | |||||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 | ||
| Today | ||||||