Struggling with Jruby Rails + jdbc driver

hi all,

I am having a hard time trying to find out what’s wrong with my setup.
used to work smoothly until I decided out of the blue to do a selfupdate
and upgrade outdated on MacPort, then things started going south very

Since MacPort kinda broke, I pull it all out and re-install the ports I
have before, which went pretty smoothly. Then to my surprise any command
issue like ruby, gem /bundle started giving me “execv failed: Permission
denied (13)” error. Not much luck googling that. So after couple hours,
pulled the whole thing as well. Remove all rubies from RVM and then
re-installing them.

I got to a point where the ruby, gem, bundle functions without problem.
firing up my test project it can no longer connect to the derby database
anymore. I tried manually adding the jdbc-derby in the gem file even
thought I know “activerecord-jdbcderby-adapter” should have that as
dependency. But it is still giving me class not found error. Suspecting
might have screwed my current project setting somehow, I created a brand
new app and added the same derby active record adaptor and jdbc-derby
in the gem file. Unfortunately I am still having the same problem listed
later in this post.

Coming from the Java world, the classpath thing is pretty easy to follow
even with maven. However I am totally scratching my head on how jruby &
rails finds and loads the java lib and I can’t seem to find any clear
on that. I can see the Any pointers on how to solve my problem and
be potential place where I should look shall be greatly appreciated!!!

I can see the jdbc-derby gem installed under my .rvm dir but have no
how it gets loaded at runtime in jruby and rails:

Error I am getting:

hello01 $ rails console
Loading development environment (Rails 3.2.12)
irb(main):001:0> User.all
NameError: cannot load Java class org.apache.derby.jdbc.ClientDriver
from org/jruby/javasupport/ for_name' from org/jruby/javasupport/’
java_import' from org/jruby/’
java_import' from /Users/josephli/.rvm/gems/jruby-1.7.2/gems/activerecord-jdbc-adapter-1.2.7/lib/arjdbc/jdbc/driver.rb:24:indriver_class’
from org/jruby/ module_eval' from /Users/josephli/.rvm/gems/jruby-1.7.2/gems/activerecord-jdbc-adapter-1.2.7/lib/arjdbc/jdbc/driver.rb:23:indriver_class’
from org/jruby/javasupport/ synchronized' from org/jruby/javasupport/’
driver_class' from /Users/josephli/.rvm/gems/jruby-1.7.2/gems/activerecord-jdbc-adapter-1.2.7/lib/arjdbc/jdbc/driver.rb:8:ininitialize’
configure_jdbc' from /Users/josephli/.rvm/gems/jruby-1.7.2/gems/activerecord-jdbc-adapter-1.2.7/lib/arjdbc/jdbc/connection.rb:24:inconfigure_connection’
initialize' from /Users/josephli/.rvm/gems/jruby-1.7.2/gems/activerecord-jdbc-adapter-1.2.7/lib/arjdbc/jdbc/adapter.rb:31:ininitialize’
… 20 levels…
to_a' from /Users/josephli/.rvm/gems/jruby-1.7.2/gems/activerecord-3.2.12/lib/active_record/explain.rb:33:inlogging_query_plan’
to_a' from /Users/josephli/.rvm/gems/jruby-1.7.2/gems/activerecord-3.2.12/lib/active_record/relation/finder_methods.rb:159:inall’
from org/jruby/ __send__' from /Users/josephli/.rvm/gems/jruby-1.7.2/gems/activerecord-3.2.12/lib/active_record/querying.rb:5:inall’
from (irb):1:in evaluate' from org/jruby/’
from org/jruby/ loop' from org/jruby/’
from org/jruby/ catch' from /Users/josephli/.rvm/gems/jruby-1.7.2/gems/railties-3.2.12/lib/rails/commands/console.rb:47:instart’
start' from /Users/josephli/.rvm/gems/jruby-1.7.2/gems/railties-3.2.12/lib/rails/commands.rb:41:in(root)’
from org/jruby/ require' from script/rails:6:in(root)'irb(main):002:0>

Any help would be appreciated,


Now this is cheating. I finally decided to add the derbyclient.jar from
maven repo to my CLASSPATH env var in my bash profile. Which get things
going for now. However, I am still baffled at what made it all work
I did the whole MacPort & RVM reinstall routine as my bash_profile
been touched for quite some time already. Which only means things was
working without adding anything to the CLASSPATH.

I said my work around is cheating since the whole Gem + bundle + Gemfile
should have made the rail app kinda self contained and shouldn’t rely on
external setting like CLASSPATH? Please correct me if I am wrong.

Anybody have similar experience?


I give up. But found a better workaround and that might just actually be
what I have done in the first place to get it working.

Turns out the jdbc-derby gem doesn’t have the derbyclient network driver
but only the embedded driver. Thus the class not found. I tried many
and thinking some combinations of the gems that I added trying to get it
work corrupted something. But still no dice. I ended up cleaning out the
jruby again from RVM. And then go on to manually removing the
corresponding gem directory (.rvm/gems).

One thing I encountered amid the removal and reinstall was getting the
following err when trying to run bundle command:

  • ......ruby_noexec_wrapper*:*7:in* `*require*': *no such file to

Solution was to set the default ruby again from rvm with the


And finally the workaround is… just stick the derbyclient driver in
the “.rvm/rubies/jruby-1.7.2/lib” directory and that loaded
and I don’t have problem with intellij anymore that way.

If anyone knows how to solve this more elegantly, please let me know.
gut feeling tells me it might involve a new gem or something, which I
know how to make yet.

*Joseph *

Thank you Jordon, for the extra info. I have not yet master enough
knowledge of how rvm works yet. I just know enough commands to monkey it
around til it works. :> Guess a visit to the rvm / bundler page will be
needed soon.


On 02/14/2013 10:13 PM, Joseph Li wrote:

One thing I encountered amid the removal and reinstall was getting the following
err when trying to run bundle command:
/ …ruby_noexec_wrapper/:/7:in/ `/require/’: /no such file to
/Solution was to set the default ruby again from rvm with the “–default”

That sir, is caused by rubygems-bundler in @global.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs