Switching to production - OCIError (ORA-12154: TNS:could not resolve the connect identifier specifi

Hi all.

Ruby version: ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
Rails version: rails 1.2.3

I finished my first RoR application (Rails and Oracle, using the oci
adapter). I am pretty close to production install time and I thought I
had done my homework and learned how to setup the production
environment:

  • I changed ‘environment.rb’ and un-commented the line
    ENV[‘RAILS_ENV’] ||= ‘production’.

  • To make sure I was using the correct database I even commented out
    the development and test sections in the ‘database.yml’ file.

When I tested the application with WEBrick everything looked good.
Then I installed Mongrel as a Windows service following the
instructions that can be found at
http://noobonrails.blogspot.com/2006/06/how-to-setup-mongrel-as-native-windows.html
and realized that something is wrong with the production environment
when I got the error.

I can indeed see the service and I can start and stop it and seems to
be working fine. But after the service is running, when I start the
application I get the error above. I also get the same error if I
start Mongrel (mongrel_rails start -p 3000 -e production) or WEBrick
(ruby script/server webrick -p 3000 -e production) manually to use the
production environment, as you can see in the -e parameter.

I have noticed that if I don’t specify the production environment
Mongrel tells me that it’s starting the development one. And both
servers do log all activity in the development log file.

What is that I am missing here to make the whole thing work in
production?

Thanks.

hey, can u post ur database.yml ? looks like production and development
connections are different and not setup correctly. Also confirm that
TNSNAMES.ORA has entry for both (dev and prod) of your config.

-Pavan

----- Original Message -----
From: “pepe” [email protected]
To: “Ruby on Rails: Talk” [email protected]
Sent: Wednesday, June 25, 2008 7:52 PM
Subject: [Rails] Switching to production - OCIError (ORA-12154:
TNS:could
not resolve the connect identifier specified):

Hello Pavan,

I don’t think the problem is in database.yml. The box where I’m trying
to make this work is a test box with same setup as the production box
will have. It has a unique database, so when I ‘switch’ between
development and production the database is actually the same. The
‘development’ and ‘test’ sections are all commented out now and
everything works fine if I start the web servers without specifying
the production environment (-e production). This is what I have in the
‘production’ section of ‘database.yml’ (I’m going by memory here):

production:
adapter: oracle
host: localhost
database: XE
user: myUser
pwd: myPassword

I don’t have 2 different entries in TNSNAMES.ORA either. I didn’t
think I needed them since there is only one database to connect to.
Does that matter?

Thanks!

Pepe

Hey Pepe,
If I understand your setup right, you have a single instance of oracle
(SID:
XE) with two users. One for development database and the other one for
production. In such a case you do not need separate TNSNAMES entries.

http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/81265d60a3d8b9e1has
some details.

Hope it helps!

Hi Pavan.

Very close but not perfect. :slight_smile:

Single instance of oracle (XE). Single database. Single user for both
development and production environments. I was just trying to switch
from ‘development’ to ‘production’ by modifying setup values and
installing Mongrel as a Windows service since it’s supposed to be
quite faster than WEBrick. Seemed simple but didn’t work for me,
giving me the OCI error I mentioned in the first post. BTW, just to
see if there is something wrong with the service I created another one
for Mongrel but in ‘development mode’ and it’s been working fine, so I
know it has nothing to do with the services.

I had just a minute yesterday to take a look at the link you posted. I
think I’ve done many of the things in it if not all but I’ll take a
closer look as soon as I can to see if there is something there that I
can use. Thanks a lot.

Pepe