Oracle_enhanced adapter 'uninitialized constant' error

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:inconst_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:inload’
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:inload’
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:inrequ
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!

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.

On Tue, Oct 28, 2008 at 1:06 PM, Cetric B. [email protected]
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

On Tue, Oct 28, 2008 at 2:02 PM, Cetric B. [email protected]
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

On Tue, Oct 28, 2008 at 2:36 PM, Todd B. [email protected]
wrote:

On Tue, Oct 28, 2008 at 2:02 PM, Cetric B. [email protected] 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 B. wrote:

On Tue, Oct 28, 2008 at 1:06 PM, Cetric B. [email protected]
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…

Cetric B. wrote:

Todd B. wrote:

On Tue, Oct 28, 2008 at 2:36 PM, Todd B. [email protected]
wrote:

On Tue, Oct 28, 2008 at 2:02 PM, Cetric B. [email protected] 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.

Todd B. wrote:

On Tue, Oct 28, 2008 at 2:36 PM, Todd B. [email protected]
wrote:

On Tue, Oct 28, 2008 at 2:02 PM, Cetric B. [email protected] 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!