views:

290

answers:

3

This was noticed in some legacy Java application (jre1.4 on HP-UX).

Parent process (shell script S1) is starting Java process, which on its own is starting child process (shell script S2). Schematically it's: S1 > Java > S2.

NB! Java application connects to Oracle DB using OCI driver.

What is strange here is that process running S1 has environment variable NLS_LANG set to american_america.BLT8MSWIN1257, Java spawns S2 using:

Runtime.getRuntime().exec(cmd);

and S2 shows that NLS_LANG is set to american_america.UTF8 (!)

This happens on some limited-access environment (production), I was not able to reproduce same problem on linux with jre 1.5.

AFAIK, Java process should inherit environment from its parrent (S1) and should pass all environment variables to its child S2 (since single argument exec call was used). However, it does not seem to be the case. Any ideas why NLS_LANG appears to be altered?

+1  A: 

Are there any logon triggers in the system? It's very common to set a lot of environment variables (generally, NLS_*_FORMAT) in logon triggers to not rely on environment configuration for system behavior.

SELECT * FROM DBA_TRIGGERS
 WHERE TRIGGERING_EVENT = 'LOGON';
Adam Musch
I'm afraid I can't check this select at the moment, but could you explain how environment of some Unix process can be altered using DB trigger?
Ralkie
I'm sorry if I was unclear; the Unix environment variable isn't modified, but the NLS_LANG parameter can be modified within the context of the Oracle session. It can be inherited from a calling process, set in all cases by the client, or overridden by a database trigger.
Adam Musch
A: 

How is NLS_LANG set ?

If you launch a program or enter another shell, that child task will not know about your environment variables unless you export them first.

Gary
Yes, NLS_LANG is exported before starting child.
Ralkie
A: 

Since NLS_LANG is exported by the parent, I'll assume it is being inherited by the child. In which case you are looking for some startup script is firing somewhere that is overwriting it with american_america.UTF8. I'd look for a .cshrc (or similar, depending on what shell S2 is). Might be in the user's area or an /etc global area.

Gary
Checked, found nothing. Thanks anyway :)
Ralkie