Imagine that you need to set up Oracle Application Express and Oracle HTTP server on an existing system (Oracle 10R2 SE on Windows 2003 server in my case).
The installation requires that you install Oracle HTTP server in a new oracle home.
After successfully installing Oracle HTTP Server (Apache) and Apex, you are so happy because everything installed seamlessly until you get a call eight hours later because some batch loader scripts stopped working.
Luckily those scripts are logging errors and what i find in the logs is the following error message:
ORA-12154: TNS:could not resolve service nameWhen you find this type of error, the best thing is to verify if you get the same error when manually connecting to the database using the same connection string from the same machine where the error was returned.
Don't try from a different client pc, because it wouldn't make sense in this case.
sqlplus user/pwd@connectorIf sqlplus returns the same error, it means that the currently used TNSNAMES.ORA does not contain a valid connector, but you go to the usual folder where the TNSNAMES.ORA file is located and everything looks fine.
So, which TNSNAMES.ORA file is being used then?
That can be easily verified using command TNSPING.
TNSPING will return the location of the TNSNAMES.ORA file being used to resolve the connector, which in turn depends on the priority of the Oracle homes and this takes us back to the beginning of this post: I've just created a new oracle home for the Oracle HTTP server and, as a consequence, the new oracle home was moved on the top of the list and therefore the TNSNAMES.ORA being used now is located in a different place. Note however that running programs may still be using the old one if they were launched before the new oracle home was created, which explains why they may still run ok.
This is why you should ALWAYS stop any processes connecting to the db when doing an installation of some component, because otherwise you can easily find in an inconsistent state: some things work, some don't and you don't understand why.
After realizing that the presence of the new oracle home caused the troubles, it's necessary to run the Oracle Installer and change the environment settings so that the "main" oracle home is restored on the top of the list.
See message translations for ORA-12154 and search additional resources.