# Oracle\_enhanced adapter 'uninitialized constant' error

**URL:** <https://www.ruby-forum.com/t/oracle-enhanced-adapter-uninitialized-constant-error/151986>\
**Category:** Ruby\
**Created:** [October 28, 2008, 6:52pm UTC](https://www.ruby-forum.com/t/oracle-enhanced-adapter-uninitialized-constant-error/151986 "2008-10-28T18:52:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![cetric\_blue](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/82dd89/32.png) [@cetric\_blue](https://www.ruby-forum.com/u/cetric_blue)\
**Post date:** [October 28, 2008, 6:52pm UTC](https://www.ruby-forum.com/t/oracle-enhanced-adapter-uninitialized-constant-error/151986/1 "2008-10-28T18:52:04Z")

</div>

Hi,

Can any one help me? I’m using Ubuntu and trying to connect to an oracle  
database using oracle\_enhanced adapter connection, but keeps getting  
following error:

/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active\_support/dependencies.  
rb:275:in `load_missing_constant': uninitialized constant ActiveRecord::Connecti onAdapters::OracleEnhancedAdapter (NameError) from /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/ dependencies.rb:467:in`const\_missing’  
from  
/home/scheng/rails/ServerMonitoringSystem/config/initializers/oracl  
e\_enhanced.rb:1  
from  
/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active\_support/  
dependencies.rb:502:in `load' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/ dependencies.rb:502:in`load’  
from  
/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active\_support/  
dependencies.rb:354:in `new_constants_in' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/ dependencies.rb:502:in`load’  
from  
/usr/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/initializer.rb:475:in `load_application_initializers' from /usr/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/initializer.rb:474:in`  
each’  
… 7 levels…  
from  
/usr/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/commands/runner.rb:39  
from  
/usr/local/lib/site\_ruby/1.8/rubygems/custom\_require.rb:27:in `gem_ original_require' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in`requ  
ire’

I have gem oracle\_enhanced-adapter, ruby\_oci8, etc. installed:

gem list

\*\*\* LOCAL GEMS \*\*\*

actionmailer (2.1.1, 2.1.0)  
actionpack (2.1.1, 2.1.0)  
activerecord (2.1.1, 2.1.0)  
activerecord-oracle-adapter (1.0.0.9250)  
activerecord-oracle\_enhanced-adapter (1.1.8)  
activeresource (2.1.1, 2.1.0)  
activesupport (2.2.0, 2.1.1, 2.1.0)  
builder (2.1.2)  
cgi\_multipart\_eof\_fix (2.5.0)  
daemons (1.0.10)  
fastthread (1.0.1)  
gem\_plugin (0.2.3)  
hpricot (0.6.161)  
markaby (0.5)  
mongrel (1.1.5)  
passenger (2.0.3)  
picnic (0.6.5)  
rack (0.4.0)  
rails (2.1.1, 2.1.0)  
rake (0.8.3)  
restr (0.4.0)  
reststop (0.3.0)  
ruby-oci8 (1.0.3)  
rubygems-update (1.3.0)  
rufus-scheduler (1.0.11)  
taskr (0.3.0)

Any ideas from any genius?

Thanks!

---

<div class="post-metadata">

**Author:** ![cetric\_blue](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/82dd89/32.png) [@cetric\_blue](https://www.ruby-forum.com/u/cetric_blue)\
**Post date:** [October 28, 2008, 7:07pm UTC](https://www.ruby-forum.com/t/oracle-enhanced-adapter-uninitialized-constant-error/151986/2 "2008-10-28T19:07:09Z")

</div>

And here is what’s in my database.yml file:

require ‘active\_record’  
require ‘rubygems’

ActiveRecord::Base.establish\_connection(  
:adapter =\> “oracle\_enhanced”,  
:database =\> “xyz”,  
:username =\> “user1”,  
:password =\> “password1”,  
:host =\> “abc.def.jkl”)

class Connect \< ActiveRecord::Base  
set\_table\_name “changelog”  
end

current\_db = Connect.find(:first, :order =\> ‘applied\_dttm DESC’)

Everything worked well in Windows, but once I moved it to Linux, things  
are so messed up.

---

<div class="post-metadata">

**Author:** ![cetric\_blue](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/82dd89/32.png) [@cetric\_blue](https://www.ruby-forum.com/u/cetric_blue)\
**Post date:** [October 28, 2008, 7:38pm UTC](https://www.ruby-forum.com/t/oracle-enhanced-adapter-uninitialized-constant-error/151986/3 "2008-10-28T19:38:01Z")

</div>

On Tue, Oct 28, 2008 at 1:06 PM, Cetric B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> :password =\> “password1”,  
> :host =\> “abc.def.jkl”)
> 
> class Connect \< ActiveRecord::Base  
> set\_table\_name “changelog”  
> end
> 
> current\_db = Connect.find(:first, :order =\> ‘applied\_dttm DESC’)
> 
> Everything worked well in Windows, but once I moved it to Linux, things  
> are so messed up.

I’m 90% sure I’m wrong on this, but you never know. Have you verified  
that the database is running (in other words, can you connect  
directly)?

One small other thing… you should require ‘rubygems’ before you  
require any other gem. That’s not part of your problem, though,  
judging by your errors. Just something to keep in mind, I suppose.

One other thing to think about is what port does the database respond  
to? Is it over the network or local?

Todd

---

<div class="post-metadata">

**Author:** ![cetric\_blue](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/82dd89/32.png) [@cetric\_blue](https://www.ruby-forum.com/u/cetric_blue)\
**Post date:** [October 28, 2008, 8:39pm UTC](https://www.ruby-forum.com/t/oracle-enhanced-adapter-uninitialized-constant-error/151986/4 "2008-10-28T20:39:39Z")

</div>

On Tue, Oct 28, 2008 at 2:02 PM, Cetric B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Todd,  
> Yes, the database is definitely running, although it is through the  
> network, but I have the port specified in ":host =\> “abc.def.jkl:1521”.
> 
> I moved require ‘rubygems’ to the top of the code, same error remains…

Cetric,  
Have you tried :port =\> 1521 as part of the hash?

Todd

---

<div class="post-metadata">

**Author:** ![cetric\_blue](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/82dd89/32.png) [@cetric\_blue](https://www.ruby-forum.com/u/cetric_blue)\
**Post date:** [October 28, 2008, 8:40pm UTC](https://www.ruby-forum.com/t/oracle-enhanced-adapter-uninitialized-constant-error/151986/5 "2008-10-28T20:40:14Z")

</div>

On Tue, Oct 28, 2008 at 2:36 PM, Todd B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> On Tue, Oct 28, 2008 at 2:02 PM, Cetric B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Todd,  
> > Yes, the database is definitely running, although it is through the  
> > network, but I have the port specified in ":host =\> “abc.def.jkl:1521”.
> > 
> > I moved require ‘rubygems’ to the top of the code, same error remains…
> 
> Cetric,  
> Have you tried :port =\> 1521 as part of the hash?

I think that might have to be :port =\> “1521” (in quotes). Untested,  
BTW.

Todd

---

<div class="post-metadata">

**Author:** ![cetric\_blue](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/82dd89/32.png) [@cetric\_blue](https://www.ruby-forum.com/u/cetric_blue)\
**Post date:** [October 28, 2008, 8:02pm UTC](https://www.ruby-forum.com/t/oracle-enhanced-adapter-uninitialized-constant-error/151986/6 "2008-10-28T20:02:49Z")

</div>

Todd B. wrote:

> On Tue, Oct 28, 2008 at 1:06 PM, Cetric B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > :password =\> “password1”,  
> > :host =\> “abc.def.jkl”)
> > 
> > class Connect \< ActiveRecord::Base  
> > set\_table\_name “changelog”  
> > end
> > 
> > current\_db = Connect.find(:first, :order =\> ‘applied\_dttm DESC’)
> > 
> > Everything worked well in Windows, but once I moved it to Linux, things  
> > are so messed up.
> 
> I’m 90% sure I’m wrong on this, but you never know. Have you verified  
> that the database is running (in other words, can you connect  
> directly)?
> 
> One small other thing… you should require ‘rubygems’ before you  
> require any other gem. That’s not part of your problem, though,  
> judging by your errors. Just something to keep in mind, I suppose.
> 
> One other thing to think about is what port does the database respond  
> to? Is it over the network or local?
> 
> Todd

Todd,  
Yes, the database is definitely running, although it is through the  
network, but I have the port specified in ":host =\> “abc.def.jkl:1521”.

I moved require ‘rubygems’ to the top of the code, same error remains…

---

<div class="post-metadata">

**Author:** ![cetric\_blue](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/82dd89/32.png) [@cetric\_blue](https://www.ruby-forum.com/u/cetric_blue)\
**Post date:** [October 28, 2008, 10:36pm UTC](https://www.ruby-forum.com/t/oracle-enhanced-adapter-uninitialized-constant-error/151986/7 "2008-10-28T22:36:42Z")

</div>

Cetric B. wrote:

> Todd B. wrote:
> 
> > On Tue, Oct 28, 2008 at 2:36 PM, Todd B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> > wrote:
> > 
> > > On Tue, Oct 28, 2008 at 2:02 PM, Cetric B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> > > 
> > > > Todd,  
> > > > Yes, the database is definitely running, although it is through the  
> > > > network, but I have the port specified in ":host =\> “abc.def.jkl:1521”.
> > > > 
> > > > I moved require ‘rubygems’ to the top of the code, same error remains…
> > > 
> > > Cetric,  
> > > Have you tried :port =\> 1521 as part of the hash?
> > 
> > I think that might have to be :port =\> “1521” (in quotes). Untested,  
> > BTW.
> > 
> > Todd
> 
> Todd,
> 
> Thanks for all your help, it turns out to be I didn’t setup  
> LD\_LIBRARY\_PATH correctly for all users. Although now I fixed the path,  
> but it gave me a new error:
> 
> /usr/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/commands/runner.rb:45:  
> env.c:257:in  
> oci8lib.so: ORA-12154: TNS:could not resolve the connect identifier  
> specified (O  
> CIError)
> 
> But that’s totally something else. I’ll do some further investigation on  
> that.
> 
> Thanks!

Just in case any one who’s interested, for the TNS error I had above, it  
was because I didn’t set the path for HOME\_ORACLE, and make sure to set  
all these paths (HOME\_ORACLE and LD\_LIBRARY\_PATH) at root level. In my  
case, I did:

su - root  
export ORACLE\_HOME=/usr/lib/oracle/11.1.0.1/client  
export LD\_LIBRARY\_PATH=$LD\_LIBRARY\_PATH:$ORACLE\_HOME/lib

I also added the above 2 lines to /etc/profile.d/oracle\_libs.sh to make  
sure it would load correctly when reboots. If you don’t have  
oracle\_libs.sh file by default, create one.

---

<div class="post-metadata">

**Author:** ![cetric\_blue](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/82dd89/32.png) [@cetric\_blue](https://www.ruby-forum.com/u/cetric_blue)\
**Post date:** [October 28, 2008, 9:41pm UTC](https://www.ruby-forum.com/t/oracle-enhanced-adapter-uninitialized-constant-error/151986/8 "2008-10-28T21:41:54Z")

</div>

Todd B. wrote:

> On Tue, Oct 28, 2008 at 2:36 PM, Todd B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > On Tue, Oct 28, 2008 at 2:02 PM, Cetric B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> > 
> > > Todd,  
> > > Yes, the database is definitely running, although it is through the  
> > > network, but I have the port specified in ":host =\> “abc.def.jkl:1521”.
> > > 
> > > I moved require ‘rubygems’ to the top of the code, same error remains…
> > 
> > Cetric,  
> > Have you tried :port =\> 1521 as part of the hash?
> 
> I think that might have to be :port =\> “1521” (in quotes). Untested,  
> BTW.
> 
> Todd

Todd,

Thanks for all your help, it turns out to be I didn’t setup  
LD\_LIBRARY\_PATH correctly for all users. Although now I fixed the path,  
but it gave me a new error:

/usr/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/commands/runner.rb:45:  
env.c:257:in  
oci8lib.so: ORA-12154: TNS:could not resolve the connect identifier  
specified (O  
CIError)

But that’s totally something else. I’ll do some further investigation on  
that.

Thanks!
