2
votes

I used rvm to install jruby (1.5.6) and installed all my gems just fine. I can run simple rails tasks like

script/runner 'puts 1'

and the output is fine. AS SOON as I hit the database I get an error. I have uninstalled/reinstalled the activerecord-jdbcmysql-adapter gem, Jruby, rvm, JAVA_JDK. I have set the JRUBY_HOME and JAVA_HOME correctly, but it seems like nothing works.

Any thoughts?

As far as I know, I have Java JDK 1.6.0 and 1.5.0 installed. IT is currently pointed to 1.6.0. But since all the other gems installed correctly, I am assuming this is something else entirely.

I am on EC2 with Ubuntu 10.04 (64 bit)

Ruby 1.9.2 with RVM works great!

nohup: ignoring input /opt/jruby/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:76:in establish_connection': Please install the jdbcmysql adapter:gem install activerecord-jdbcmysql-adapter(no such file to load -- active_record/connection_adapters/jdbcmysql_adapter) (RuntimeError) from /opt/jruby/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:60:inestablish_connection' from /opt/jruby/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:55:in establish_connection' from /opt/jruby/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/initializer.rb:438:ininitialize_database' from /opt/jruby/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/initializer.rb:141:in process' from /opt/jruby/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/initializer.rb:113:inrun' from /home/tesmar/rails/statsheet/config/environment.rb:19 from /home/tesmar/rails/statsheet/config/environment.rb:39:in require' from /opt/jruby/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/commands/runner.rb:39 from /opt/jruby/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/commands/runner.rb:3:inrequire' from script/runner:3

4
I should add that the database.yml points to the right adapter.tesserakt
I should also add that I don't understand how voting works around here. For ex: I voted down Dex's answer to -1 while voting up Mark's. Now dex shows 0 and Mark shows the appropriate 1. Does my vote not count?tesserakt

4 Answers

1
votes

As the error message says, you need to install the activerecord-jdbcmysql-adapter gem.

It is possible that your execution environment is different from your rvm environment. I've seen this happen with IDEs such as NetBeans.

1
votes

How do your gemfile look like?

Mine looks like this and work:

source 'http://rubygems.org'

gem 'rails', '3.0.4'


platforms :ruby do
  gem 'mysql2'
end

platforms :jruby do
  gem 'activerecord-jdbc-adapter'
  gem 'jdbc-mysql', :require => false
end
0
votes

If you are going back and forth between jRuby and MRI, you can add something like this to your Gemfile too:

if defined?(JRUBY_VERSION)
   gem 'jdbc-mysql'
   gem 'activerecord-jdbc-adapter'
   gem 'activerecord-jdbcmysql-adapter'
   gem 'warbler'
else
   gem 'mysql'
   gem 'mongrel'
end

Then, in your database.yml add something like this:

development:

    adapter: <%= defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql' %>
-2
votes

I figured it out. I had to download the JAR file, after copying manually all the rb files into the active record gem (the rb files from the activerecord-jdbcmysql and activerecord-jdbc gems). I then put the JAR file in the /opt/jruby/lib directory and it works! Woohoo!