Thursday April 03, 2008
This blog provides how you can get started with Merb on JRuby
1.1 RC3.
Merb is another MVC framework (just like Rails) but with a pluggable
ORM, JavaScript library and Template language. Rails has built-in
support for these using ActiveRecord, Script.aculo.us
and ERB
templates. Making it pluggable keeps the core very lightweight and
still providing support for a particular feature using plugins. Another
big advantage of Merb is that unlike Rails it's thread-safe.
There
are already third party supports for ActiveRecord, DataMapper and
Sequel ORMs. I will hopefully be able to build support for Java
Persistence API ORM in Merb. Until then, here is how you
install and get started with Merb on JRuby 1.1 RC3.
Install Merb on JRuby as:
| Macintosh-187:jruby-1.1RC3
arungupta$ bin/jruby -S
gem install merb mongrel JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Updating metadata for 339 gems from http://gems.rubyforge.org ......................................................................................................... ......................................................................................................... ......................................................................................................... ........................ complete Successfully installed abstract-1.0.0 Successfully installed erubis-2.5.0 Successfully installed json_pure-1.1.2 Successfully installed rack-0.3.0 Successfully installed hpricot-0.6-java Successfully installed mime-types-1.15 Successfully installed merb-core-0.9.2 Successfully installed merb-action-args-0.9.2 Successfully installed merb-assets-0.9.2 Successfully installed activesupport-2.0.2 Successfully installed rubigen-1.2.4 Successfully installed merb-gen-0.9.2 Successfully installed merb-haml-0.9.2 Successfully installed merb-builder-0.9.2 Successfully installed mailfactory-1.2.3 Successfully installed merb-mailer-0.9.2 Successfully installed merb-parts-0.9.2 Successfully installed merb-cache-0.9.2 Successfully installed merb-more-0.9.2 Successfully installed merb-0.9.2 Successfully installed gem_plugin-0.2.3 Successfully installed mongrel-1.1.4-java 22 gems installed Installing ri documentation for json_pure-1.1.2... Installing ri documentation for rack-0.3.0... Installing ri documentation for hpricot-0.6-java... Installing ri documentation for mime-types-1.15... Installing ri documentation for merb-core-0.9.2... Installing ri documentation for merb-action-args-0.9.2... Installing ri documentation for merb-assets-0.9.2... Installing ri documentation for activesupport-2.0.2... Installing ri documentation for rubigen-1.2.4... Installing ri documentation for merb-gen-0.9.2... Installing ri documentation for merb-haml-0.9.2... Installing ri documentation for merb-builder-0.9.2... Installing ri documentation for mailfactory-1.2.3... Installing ri documentation for merb-mailer-0.9.2... Installing ri documentation for merb-parts-0.9.2... Installing ri documentation for merb-cache-0.9.2... Installing ri documentation for gem_plugin-0.2.3... Installing ri documentation for mongrel-1.1.4-java... Installing RDoc documentation for json_pure-1.1.2... Installing RDoc documentation for rack-0.3.0... Installing RDoc documentation for hpricot-0.6-java... Installing RDoc documentation for mime-types-1.15... Installing RDoc documentation for merb-core-0.9.2... Installing RDoc documentation for merb-action-args-0.9.2... Installing RDoc documentation for merb-assets-0.9.2... Installing RDoc documentation for activesupport-2.0.2... Installing RDoc documentation for rubigen-1.2.4... Installing RDoc documentation for merb-gen-0.9.2... Installing RDoc documentation for merb-haml-0.9.2... Installing RDoc documentation for merb-builder-0.9.2... Installing RDoc documentation for mailfactory-1.2.3... Installing RDoc documentation for merb-mailer-0.9.2... Installing RDoc documentation for merb-parts-0.9.2... Installing RDoc documentation for merb-cache-0.9.2... Installing RDoc documentation for gem_plugin-0.2.3... Installing RDoc documentation for mongrel-1.1.4-java... |
| Macintosh-187:jruby-1.1RC3
arungupta$ cd samples/ Macintosh-187:samples arungupta$ mkdir merb Macintosh-187:samples arungupta$ cd merb/ Macintosh-187:merb arungupta$ ../../bin/jruby -S merb-gen app hello RubiGen::Scripts::Generate create app create autotest create config create public create spec create app/controllers create app/helpers create app/views create app/views/exceptions create app/views/layout create config/environments create public/images create public/stylesheets create autotest/discover.rb create autotest/merb.rb create autotest/merb_rspec.rb create config/rack.rb create config/router.rb create config/init.rb create public/merb.fcgi create spec/spec.opts create spec/spec_helper.rb create app/controllers/application.rb create app/controllers/exceptions.rb create app/helpers/global_helpers.rb create app/views/exceptions/internal_server_error.html.erb create app/views/exceptions/not_acceptable.html.erb create app/views/exceptions/not_found.html.erb create app/views/layout/application.html.erb create config/environments/development.rb create config/environments/production.rb create config/environments/rake.rb create config/environments/test.rb create public/images/merb.jpg create public/stylesheets/master.css create /Rakefile |
| Macintosh-187:hello
arungupta$ ls -la total 8 drwxr-xr-x 8 arungupta arungupta 272 Apr 1 22:20 . drwxr-xr-x 3 arungupta arungupta 102 Apr 1 22:20 .. -rw-r--r-- 1 arungupta arungupta 3334 Apr 1 22:20 Rakefile drwxr-xr-x 5 arungupta arungupta 170 Apr 1 22:20 app drwxr-xr-x 5 arungupta arungupta 170 Apr 1 22:20 autotest drwxr-xr-x 6 arungupta arungupta 204 Apr 1 22:20 config drwxr-xr-x 5 arungupta arungupta 170 Apr 1 22:20 public drwxr-xr-x 4 arungupta arungupta 136 Apr 1 22:20 spec |
| Macintosh-187:hello
arungupta$ ../../../bin/jruby
-S merb JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL ~ Loaded DEVELOPMENT Environment... ~ Compiling routes... ~ Using 'share-nothing' cookie sessions (4kb limit per client) ~ Using Mongrel adapter |

Posted by Arun Gupta in web2.0 | Comments[6]
|
|
|
|
|
Today's Page Hits: 1606
Total # blog entries: 1002
This is very cool. I've been meaning to give Merb a go on JRuby, now I don't have an excuse:).
Posted by Jonathan Conway on April 07, 2008 at 02:51 AM PDT #
I want to thank you for your posts on merb/rails & glassfish.
And I'm really interested on one of your last sentences
'If possible, use WARbler to package Merb app and deploy on GlassFish.'
Do you have more infos or could you write more on this?
Thanks again!
Posted by ettober on April 23, 2008 at 06:55 AM PDT #
ettober,
This is an area of investigation for myself :) At this point, I don't know if Warbler supports packaging Merb applications as WAR and then deploy on GlassFish. Another option that I'll try is native deployment of Merb apps on GlassFish. Purely an area of investigation and possible food of thought for others ...
-Arun
Posted by Arun Gupta on April 23, 2008 at 06:58 AM PDT #
Arun --
Why would Warbler be designed only to package Rails applications? If it is so specific, then it really ought to be redesigned, as merb is just one example of the new frameworks that would greatly benefit from a 'deploy to Glassfish' option. I am developing for Waves (http://rubywaves.com), myself, and will be looking into deploying it into glassfish in the near future. Unfortunately, there are ZERO docs for how to undertake this. Certainly if you (awesome) folks at Sun can work on easy deployment of any framework that uses rack, then jruby and glassfish will enter a new phase of being the darling of the New.
Sun is already well positioned with NetBeans 6.1 incredible Ruby support. Unfortunately that effort also seems to be suffering from the 'Rails is Ruby' fallacy. Sun has nothing but marketshare to rake in. Please use your position from the inside to make sure they don't shoot themselves in the foot by only catering to the one framework that Rubyists are moving AWAY from.
Posted by ab5ract on May 05, 2008 at 05:33 PM PDT #
ab5ract,
Rack-based deployment now work on GlassFish. Read more details at:
http://blogs.sun.com/arungupta/entry/war_based_packaging_and_deployment
Let me know if you have any questions while moving to GlassFish.
-Arun
Posted by Arun Gupta on May 19, 2008 at 02:37 PM PDT #
I've just set up a combination of JRuby + Glassfish + Merb. See http://blog.nodeta.fi/2008/05/22/living-on-the-edge-jruby-merb-glassfish/ for more information.
Posted by Otto Hilska on May 22, 2008 at 03:01 PM PDT #