# Struggling with Jruby Rails + jdbc driver

**URL:** <https://www.ruby-forum.com/t/struggling-with-jruby-rails-jdbc-driver/229767>\
**Category:** Rails\
**Created:** [February 14, 2013, 11:03pm UTC](https://www.ruby-forum.com/t/struggling-with-jruby-rails-jdbc-driver/229767 "2013-02-14T23:03:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joseph\_Li](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b77776/32.png) [@Joseph\_Li](https://www.ruby-forum.com/u/Joseph_Li)\
**Post date:** [February 14, 2013, 11:03pm UTC](https://www.ruby-forum.com/t/struggling-with-jruby-rails-jdbc-driver/229767/1 "2013-02-14T23:03:29Z")

</div>

hi all,

I am having a hard time trying to find out what’s wrong with my setup.  
It  
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  
quickily.

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  
I  
issue like ruby, gem /bundle started giving me “execv failed: Permission  
denied (13)” error. Not much luck googling that. So after couple hours,  
I  
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.  
Now  
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  
I  
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  
gem  
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  
info  
on that. I can see the Any pointers on how to solve my problem and  
might  
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  
idea  
how it gets loaded at runtime in jruby and rails:  
./gems/jruby-1.7.2/gems/jdbc-derby-10.8.3.0  
./gems/jruby-1.7.2/gems/jdbc-derby-10.8.3.0/lib  
./gems/jruby-1.7.2/gems/jdbc-derby-10.8.3.0/lib/derby-10.8.3.0.jar  
./gems/jruby-1.7.2/gems/jdbc-derby-10.8.3.0/lib/jdbc  
./gems/jruby-1.7.2/gems/jdbc-derby-10.8.3.0/lib/jdbc/derby.rb  
./gems/jruby-1.7.2/gems/jdbc-derby-10.8.3.0/LICENSE.txt  
./gems/jruby-1.7.2/gems/jdbc-derby-10.8.3.0/Rakefile  
./gems/jruby-1.7.2/gems/jdbc-derby-10.8.3.0/README.md

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/JavaClass.java:1227:in `for_name' from org/jruby/javasupport/JavaUtilities.java:34:in`get\_proxy\_class’  
from  
file:/Users/josephli/.rvm/rubies/jruby-1.7.2/lib/jruby.jar!/jruby/java/core\_ext/object.rb:26:in  
`java_import' from org/jruby/RubyArray.java:2361:in`map’  
from  
file:/Users/josephli/.rvm/rubies/jruby-1.7.2/lib/jruby.jar!/jruby/java/core\_ext/object.rb:22:in  
`java_import' from /Users/josephli/.rvm/gems/jruby-1.7.2/gems/activerecord-jdbc-adapter-1.2.7/lib/arjdbc/jdbc/driver.rb:24:in`driver\_class’  
from org/jruby/RubyModule.java:2291:in `module_eval' from /Users/josephli/.rvm/gems/jruby-1.7.2/gems/activerecord-jdbc-adapter-1.2.7/lib/arjdbc/jdbc/driver.rb:23:in`driver\_class’  
from org/jruby/javasupport/JavaObject.java:272:in `synchronized' from org/jruby/javasupport/JavaProxyMethods.java:90:in`synchronized’  
from  
/Users/josephli/.rvm/gems/jruby-1.7.2/gems/activerecord-jdbc-adapter-1.2.7/lib/arjdbc/jdbc/driver.rb:20:in  
`driver_class' from /Users/josephli/.rvm/gems/jruby-1.7.2/gems/activerecord-jdbc-adapter-1.2.7/lib/arjdbc/jdbc/driver.rb:8:in`initialize’  
from  
/Users/josephli/.rvm/gems/jruby-1.7.2/gems/activerecord-jdbc-adapter-1.2.7/lib/arjdbc/jdbc/connection.rb:44:in  
`configure_jdbc' from /Users/josephli/.rvm/gems/jruby-1.7.2/gems/activerecord-jdbc-adapter-1.2.7/lib/arjdbc/jdbc/connection.rb:24:in`configure\_connection’  
from  
/Users/josephli/.rvm/gems/jruby-1.7.2/gems/activerecord-jdbc-adapter-1.2.7/lib/arjdbc/jdbc/connection.rb:82:in  
`initialize' from /Users/josephli/.rvm/gems/jruby-1.7.2/gems/activerecord-jdbc-adapter-1.2.7/lib/arjdbc/jdbc/adapter.rb:31:in`initialize’  
… 20 levels…  
from  
/Users/josephli/.rvm/gems/jruby-1.7.2/gems/activerecord-3.2.12/lib/active\_record/relation.rb:160:in  
`to_a' from /Users/josephli/.rvm/gems/jruby-1.7.2/gems/activerecord-3.2.12/lib/active_record/explain.rb:33:in`logging\_query\_plan’  
from  
/Users/josephli/.rvm/gems/jruby-1.7.2/gems/activerecord-3.2.12/lib/active\_record/relation.rb:159:in  
`to_a' from /Users/josephli/.rvm/gems/jruby-1.7.2/gems/activerecord-3.2.12/lib/active_record/relation/finder_methods.rb:159:in`all’  
from org/jruby/RubyBasicObject.java:1659:in ` __send__' from /Users/josephli/.rvm/gems/jruby-1.7.2/gems/activerecord-3.2.12/lib/active_record/querying.rb:5:in`all’  
from (irb):1:in `evaluate' from org/jruby/RubyKernel.java:1066:in`eval’  
from org/jruby/RubyKernel.java:1392:in `loop' from org/jruby/RubyKernel.java:1174:in`catch’  
from org/jruby/RubyKernel.java:1174:in `catch' from /Users/josephli/.rvm/gems/jruby-1.7.2/gems/railties-3.2.12/lib/rails/commands/console.rb:47:in`start’  
from  
/Users/josephli/.rvm/gems/jruby-1.7.2/gems/railties-3.2.12/lib/rails/commands/console.rb:8:in  
`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/RubyKernel.java:1027:in `require' from script/rails:6:in`(root)'irb(main):002:0\>

Any help would be appreciated,

Joseph

---

<div class="post-metadata">

**Author:** ![Joseph\_Li](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b77776/32.png) [@Joseph\_Li](https://www.ruby-forum.com/u/Joseph_Li)\
**Post date:** [February 14, 2013, 11:42pm UTC](https://www.ruby-forum.com/t/struggling-with-jruby-rails-jdbc-driver/229767/2 "2013-02-14T23:42:38Z")

</div>

Now this is cheating. I finally decided to add the derbyclient.jar from  
the  
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  
before  
I did the whole MacPort & RVM reinstall routine as my bash\_profile  
hasn’t  
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?

Thanks,  
Joseph

---

<div class="post-metadata">

**Author:** ![Joseph\_Li](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b77776/32.png) [@Joseph\_Li](https://www.ruby-forum.com/u/Joseph_Li)\
**Post date:** [February 15, 2013, 5:15am UTC](https://www.ruby-forum.com/t/struggling-with-jruby-rails-jdbc-driver/229767/3 "2013-02-15T05:15:18Z")

</div>

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  
things  
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

```

load…\*  
_Solution was to set the default ruby again from rvm with the  
“–default”  
option._  
\*  
\*

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

_If anyone knows how to solve this more elegantly, please let me know.  
My  
gut feeling tells me it might involve a new gem or something, which I  
don’t  
know how to make yet._  
\*  
\*  
\*Joseph \*  
\*  
\*  
\*  
\*  
\*  
\*

---

<div class="post-metadata">

**Author:** ![Joseph\_Li](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b77776/32.png) [@Joseph\_Li](https://www.ruby-forum.com/u/Joseph_Li)\
**Post date:** [February 15, 2013, 5:42am UTC](https://www.ruby-forum.com/t/struggling-with-jruby-rails-jdbc-driver/229767/4 "2013-02-15T05:42:46Z")

</div>

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.

Thanks,  
Joseph

---

<div class="post-metadata">

**Author:** ![Joseph\_Li](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b77776/32.png) [@Joseph\_Li](https://www.ruby-forum.com/u/Joseph_Li)\
**Post date:** [February 15, 2013, 5:18am UTC](https://www.ruby-forum.com/t/struggling-with-jruby-rails-jdbc-driver/229767/5 "2013-02-15T05:18:14Z")

</div>

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  
> load…/  
> /Solution was to set the default ruby again from rvm with the “–default”  
> option./

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