开发者

JRuby cannot use the adapter I installed

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, 开发者_StackOverflowbut 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


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.


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


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' %>


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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜