I recently transitioned a Ruby on Rails Passenger server to jRuby with Tomcat and encountered an error caused by the Gemfile.
“no such file to load — mysql2/mysql2
LoadError: no such file to load — mysql2/mysql2”
The fix? JRuby needs a MySQL adapter named “activerecord-jdbcmysql-adapter” in order to it to work properly.
# Original MySQL Adapter -- # gem 'mysql2', '~>0.3.13' # # New Adapter for jRuby gem 'activerecord-jdbcmysql-adapter'
Adding the ‘activerecord-jdbcmysql-adapter’ gem and commenting out the original “mysql2” gem fixed the issue. I recommend using the “warble executable war” to troubleshoot these errors since you can quickly run a “java -jar myapp.war” to test it out.
Tested with jRuby 1.7.4, Rails 3.2.12