"We access and use standard environment variables in our Java code. It works with other vendors products, but when we deploy it to OC4J running within Oracle Application Server, the code no longer works. How can we use environment variables?"
Answer:
In the Oracle Application Server architecture, the OC4J process is started by the OPMN process. The model that is employed results in no environment variables that are set when OPMN is launched being passed to the processes that OPMN starts.
If you want to set specific environment variables for OPMN managed processes to use, then you must do it by setting the environment variable name and value in the opmn.xml file. OPMN will then pass the environment variable to the process(es) it starts.
<ias-instanceid="ias-instance-id" ... ">
<environment>
<variableid="id" value="value" append="boolean"/>
</environment>
<ias-component id="ias-component-id">>
...
</ias-component id="ias-component-id">>
</ias-instanceid>
It's worth noting that the <environment> tag can be used in multiple places within the opmn.xml file to allow the correct scope (or additive effect) to be defined.Once the environment variable has been set, it can be accessed from within an applictation running within an OPMN managed OC4J instance using the standard Java API:
System.getenv("envvar")
;
1 comment:
System.getenv is deprecated.
ksahni@etcc.com
Post a Comment