JRuby on Rails with Nine Lives: Running a JRuby on Rails Application on Tomcat, Page 2
Installing Goldspike
To get your app to deploy to a Java server, you must install a Rails Integration plugin called Goldspike.
Change to the railswartest directory and run the following command to add the plugin to your app:
jruby script/plugin install svn://rubyforge.org/var/svn/ jruby-extras/trunk/rails-integration/plugins/goldspike
Click here for a larger image.
Figure 4: Installing Goldspike into your JRuby on Rails application
Goldspike adds some new rake (Ruby version of Make) tasks that allow you to create a WAR (Web Application ARchive) file of your Rails application. WAR files are the standard way of packaging and deploying Java-based web applications. Run the following command to ensure you have the war rake tasks available now to your app:
jruby S rake tasks
MySQL JDBC Driver Installation and Configuration
You will use MySQL for your database. You need to download the MySQL 5 JDBC driver and extract it into a directory. There will be a MySQL JDBC driver file mysql-connector-java-5.0.6-bin.jar in the directory. Copy this file into the $JRUBY_HOME/lib directory and rename it to mysql-connector-java-5.0.6.jar:
Click here for a larger image.
Figure 5: Installing MySQL JDBC driver into JRuby
You will need to add the MySQL JDBC 5 driver to the list of Java libraries that the Goldspike plugin includes when it builds the WAR file for your application. It will pick this file up from the $JRUBY_HOME/lib directory. Within the railswartest directory, edit the vendor/plugins/goldspike/lib/war_config.rb file and the following to the java_libraries list:
add_java_library(maven_library ('mysql', 'mysql-connector-java',
'5.0.6'))
Click here for a larger image.
Figure 6: Adding the MySQL 5 JDBC driver to the Goldspike Java libraries list
