Monday April 07, 2008
Rails and Java EE integration - Warbler instead of Goldspike
Part
1 of this tri-series blog explained how a Java EE
Servlet and Rails application can be packaged together as WAR file
using Goldspike
plugin and deployed on GlassFish
v2 UR1. There are few issues with Goldspike as explained here.
A better and recommended option is to use Warbler
for packaging which provides a minimal, flexible and Ruby-like way to
create WAR. Warbler really cleans up the packagingof WAR, for example
excluding .svn directories, tests and migrations - really nice. For
now, it uses RailsServlet for dispatching but even that is pluggable.
This blog, Part 2, will explain how to generate a WAR file using
Warbler. Rails
powered by GlassFish provides all the details on why
GlassFish provides an industry-grade and functionally-rich Application
Server.
Now detailed steps:
| ~/testbed/jruby-1.1
>bin/jruby -S gem
install warbler JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Updating metadata for 35 gems from http://gems.rubyforge.org ................................... complete Successfully installed warbler-0.9.4 1 gem installed Installing ri documentation for warbler-0.9.4... Installing RDoc documentation for warbler-0.9.4... |
|
~/testbed/jruby-1.1/samples/rails >../../bin/jruby -S rails
railsee2 create create app/controllers create app/helpers create app/models . . . create log/production.log create log/development.log create log/test.log |
| config.frameworks -= [ :active_record, :active_resource, :action_mailer ] |
| <!DOCTYPE
web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <servlet> <servlet-name>HelloServlet</servlet-name> <servlet-class>server.HelloServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>HelloServlet</servlet-name> <url-pattern>/hello</url-pattern> </servlet-mapping> </web-app> |
| ~/testbed/jruby-1.1/samples/rails/railsee2
>~/testbed/jruby-1.1/bin/jruby
-S warble JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL jar cf railsee2.war -C tmp/war . |
| ~/testbed/jruby-1.1/samples/rails/railsee2
>~/testbed/glassfish/v2ur1/glassfish/bin/asadmin
deploy railsee2.war Command deploy executed successfully. |


| ~/testbed/jruby-1.1/samples/rails/railsee2
>../../../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 |
| class
HomeController < ApplicationController include Java def index url = java.net.URL.new("http://localhost:8080/railsee2/hello"); conn = url.open_connection; reader = java.io.BufferedReader.new(java.io.InputStreamReader.new(conn.get_input_stream)); @servlet_output = ""; input_line = reader.read_line; while input_line != nil @servlet_output << input_line; input_line = reader.read_line; end reader.close; end end |
| <h1>Home#index</h1> <p>Find me in app/views/home/index.html.erb</p> <%= @servlet_output %> |

Posted by Arun Gupta in web2.0 | Comments[9]
|
|
|
|
|
Today's Page Hits: 992
Total # blog entries: 994
| « November 2009 | ||||||
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
1 | 2 | 4 | 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 | |||||
| Today | ||||||
Nice blog
Posted by Guddu on April 08, 2008 at 11:24 PM PDT #
Posted by Arun Gupta's Blog on April 14, 2008 at 08:20 AM PDT #
In step #4 above, I think you mean bullet #4 of the other blog.
Cheers,
Bobby
Posted by Bobby Bissett on August 21, 2008 at 09:11 AM PDT #
Posted by Arun Gupta's Blog on September 05, 2008 at 10:19 PM PDT #
cool thing there is that you don't need Goldspike, Warbler right dude...
Posted by Girl Pics on March 08, 2009 at 02:29 PM PDT #
Great article, beacause i was generating the WAR file with Goldspike, but Goldspike is deprecated, so Wabler really help me a lot. I will visit your blog constantly because now i'm on a jruby/blazeDs/glassfish project for my degree in Computer Science (University).
Greetings.
Posted by Alexis Tejeda on June 25, 2009 at 01:16 AM PDT #
Alexis, please let us know once your project is complete. Do you plan to publish a blog entry describing the details ?
Posted by Arun Gupta on July 02, 2009 at 10:22 AM PDT #
Hi Arun, in few words, i'm integrating BlazeDs (live cycle data from Adobe) with Jruby (with rails), but i'm experimenting some troubles with a servlet mapping of BlazeDs, if you have time to help me with this big-tiny issue please contact me in my email alexis.tejeda [At] gmail Dot com, thanks in advance.
Posted by Alexis Tejeda on July 10, 2009 at 12:15 PM PDT #
Alexis, I've not played with BlazeDS so don't how much I can help but sent you an email and we can discuss there.
Posted by Arun Gupta on July 10, 2009 at 12:26 PM PDT #