I generated a new Torquebox Rails app and copied my app into the
hierarchy.
I did a bundle install after all gems were added to the Gemfile and now
it looks like webrick pukes when attempting to load the mysql driver:
ActiveRecord::JDBCError: The driver encountered an unknown error: cannot
load Java class com.mysql.jdbc.Driver
initialize at
/home/jim/bin/torquebox-2.2.0/jruby/lib/ruby/gems/shared/gems/activerecord-jdbc-adapter-1.2.2.1/lib/arjdbc/jdbc/connection.rb:91
initialize at
/home/jim/bin/torquebox-2.2.0/jruby/lib/ruby/gems/shared/gems/activerecord-jdbc-adapter-1.2.2.1/lib/arjdbc/jdbc/adapter.rb:33
initialize at
/home/jim/bin/torquebox-2.2.0/jruby/lib/ruby/gems/shared/gems/activerecord-jdbc-adapter-1.2.2.1/lib/arjdbc/mysql/adapter.rb:465
jdbc_connection at
/home/jim/bin/torquebox-2.2.0/jruby/lib/ruby/gems/shared/gems/activerecord-jdbc-adapter-1.2.2.1/lib/arjdbc/jdbc/connection_methods.rb:6
mysql_connection at
/home/jim/bin/torquebox-2.2.0/jruby/lib/ruby/gems/shared/gems/activerecord-jdbc-adapter-1.2.2.1/lib/arjdbc/mysql/connection_methods.rb:19 send at
org/jruby/RubyBasicObject.java:1665
send at
org/jruby/RubyKernel.java:2090
I’m using the JRuby from the Torquebox install as my default system
Ruby. (well, JRuby actually, I nuked RVM so now I need to type “jruby
-S” before all my commands)
Is anyone else using MySQL with the latest JRuby, Rails and Torquebox?
Anyone else got it working?
I realize this shouldn’t be necessary, but it may be a step in the right
direction. Having the gem in the Gemfile makes it available to the
application, but what actually loads (or requires) it at runtime? Maybe
answering this question would lead us to the solution.
I guess until we figure it out, you could just do the same CLASSPATH
hack and it might work.
Putting gem ‘jdbc-mysql’, ‘5.1.13’ in your Gemfile should fix the error.
The issue is because of an incompatibility between the new jdbc-* gems
and the version of activerecord-jdbc-adapter that is out. You can find
more discussion about the issue here:
This seems like a significant problem that could discourage JRuby
adoption and make JRubyists less productive. What’s up with this
incompatibility? Is it a challenging issue, technically? Or are the
authors/contributors too busy with other things? I don’t mean to be
critical, I know I’m not contributing to the solution, but I’m curious.
If you’re new to JRuby adoption, I gotta tell ya… this is kinda par
for the course. I don’t mean to sound discouraging at all as I feel we
have some of the smartest minds working on the issues, and I LOVE
working with this stack. But, I also think there are so many plates
spinning in the air, that the JRuby developers alone can’t truly address
all the issues. We have the JVM which runs JRuby, which runs Rails…
which uses myriad gems to accomplish many different goals.
I do feel the same way every time I go to update to some newer version
and get “Ruby Vomit” all over my console. There is a part of me that
says, “Can’t it just work… just once? Do I have to fight it every
time??? Could it be more like other stacks that just seem to work???”
It’ll get better… but we need to remember that we’re working with an
amazing “work in progress”. Cheers to the people that make it happen!
The recently TorqueBox 2.3.0 ships with distributed transaction support
disabled by default for databases which should get things working again
with ActiveRecord-JDBC 1.2.5.
If you’re on an older version of TorqueBox, try adding ‘xa: false’ to
your database.yml entry and things should work on AR-JDBC 1.2.5.