1. Download JRuby: http://jruby.codehaus.org/
2. Get the IBM Java SDK IBM JAVA SDK: http://www.ibm.com/developerworks/java/jdk/eclipse/index.html or the SUN JAVA JDK http://java.sun.com/javase/downloads/index.jsp
3. Copy/Install the SDK into your Java folder of choice e.g. C:\Program Files\Java on Windows or /opt/java/ on Linux
4. Start the Command Line. Set the JAVA_HOME environment variable to the path of your SDK: e.g. Windows: set JAVA_HOME=C:\Program Files\Java\IBM-SDK-Whichversionever Linux: export JAVA_HOME=/opt/IBM_SDK-Whichversionever
5. Unpack the JRuby archive to your folder of choice.
6. Go back to the command prompt and set your JRUBY_HOME variable to the path where you unpacked Jruby
7. Add your Jruby/bin path to the PATH variable. e.g. Linux: export PATH=$PATH:$JRUBY_HOME/bin
8. Create a folder for your projects e.g.: mkdir c:\railsprojects
9. Install Rails: Back to the comamnd line issue: "gem install rails -y --no-rdoc --no-ri"
10. Install JDBC driver support: "gem install activerecord-jdbc-adapter -y --no-rdoc --no-ri"
11. Go the your Rails projects folder e.g. the created C:\railsprojects
12. Issue: rails myapp
13. Wait until the Rails application skeleton is created
14. Install Warbler (WAR-File packaging plugin to deploy Rails applications to Application Servers) "gem install warbler -y --no-rdoc --no-ri "
15.Change directoy to your new Rails application : cd myapp
16. CD to /public
17. Edit index.html
Go to line 65:
background-image: url("images/rails.png");
Change to:
background-image: url("/myapp/images/rails.png");
Go to line 181 + 182: <script type="text/javascript" src="javascripts/prototype.js"></script> <script type="text/javascript" src="javascripts/effects.js"></script> Change to: <script type="text/javascript" src="/myapp/javascripts/prototype.js"></script> <script type="text/javascript" src="/myapp/javascripts/effects.js"></script>
Go to line 186:
new Ajax.Updater('about-content', 'rails/info/properties', {
Change to:
new Ajax.Updater('about-content', '/myapp/rails/info/properties', {
Go to line 244: <h3><a href="rails/info/properties" onclick="about(); return false">About your application’s environment</a></h3> Change to: <h3><a href="/myapp/rails/info/properties" onclick="about(); return false">About your application’s environment</a></h3>
done!
18. Ok, almost ready, now change Warbler XML configuration to be WebSphere compatible: Go to : $JRUBY_HOME/lib/ruby/gems/1.8/gems/warbler-0.9.10 (Warbler Version my change) Now find the file web.xml.erb in that directory. Make a backup copy (IMPORTANT, if you like to use your Jruby Apps for e.g. Tomcat later too, so you can change the xml files again) Edit web.xml.erb and replace the whole content of the file with this:
<!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>
<% webxml.context_params.each do |k,v| %>
<context-param>
<param-name><%= k %></param-name>
<param-value><%= v %></param-value>
</context-param>
<% end %>
<listener>
<listener-class><%= webxml.servlet_context_listener %></listener-class>
</listener>
<servlet>
<servlet-name>Rails</servlet-name>
<servlet-class>org.jruby.rack.RackServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Rails</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<% if webxml.jndi then webxml.jndi.each do |jndi| %>
<resource-ref>
<res-ref-name><%= jndi %></res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<% end; end %>
</web-app>
19. Ok change directoy to the root of your Ruby app and issue : Jruby -S warble
20. When warbler is ready you will find myapp.war in that root directory.
21. Deploy with context root: /myapp
READY!
Hints:
When you issue Jruby -S warble config in the root directory of the Rails app, Warbler will create the configuration file /config/warbler.rb. You can now edit several things and repackage the Rails app, e.g. "production" or "development" version of deployment, which should be necessary to be able to click on the "About your environment" button in the Jruby app skeleton, even though we dont have a derby database configured yet, which will result in an error saying, no sqlite3 configured (database default for Jruby on Rails apps) You will might need to edit /config/environment.rb too. Change row 5: #ENV['RAILS_ENV'] ||= 'production' to ENV['RAILS_ENV'] ||= 'development'
JRuby -S warble clean, will clean up temporary folders and delete the war file.
A lot of people also recommend to freeze your Rails app before deployment. In the root directoy for your Rails app issue: jruby -S rake rails:freeze:gems
..and repackage with warbler.
With the Application Server Toolkit it should be easily possible to create an Ear file with the context root predefined and you can edit the index.html directly in WAR file, so you can have
a ready to deploy sample for your friends
Next important topics: RACF,IMS,DB2,CICS integration….