Tuesday, December 22, 2015

Apply EBS R12.1 CPU patches (October 2015)

Apps CPU (Critical Patch Update) patches involve different areas. Normally CPU patches are applied at the same time to EBS apps and two ORACLE_HOMEs. Doc ID 2051000.1 has the instruction for October 2015 CPU patches.

1. Database patches

In my 12.1.0.2 database, database October 2015 PSU and other patches were applied. But most of them are for other purposes, and are not pre-requisites for EBS Oct 2015 CPU.
    Patch            Conflict patch
    21520444    Combo of 12.1.0.2.5 OJVM PSU and 12.1.0.2.5 DB PSU (Oct 2015)
    6880880      Latest OPatch
X 19382851     Already included in 12.1.0.2.5 PSU
X 19393542     Already included in 12.1.0.2.5 PSU
X 19627012     Already included in 12.1.0.2.5 PSU
X 19649152     Already included in 12.1.0.2.5 PSU
    20204035    12.1.0.2.0 version. No conflicts
    13542050    A mutex related hang with holder around 65534 (0xfffe)
    19855835    Upgrade slow when reorganizing large stats history tables
    20879889    Open cursor leak from DML on table with a materialized view log
    20807398    ORA-600 [kgl-hash-collision] with fix to bug 20465582 installed
    21091518    Extend fix of bug 18304693 to Partition Views

2. Patch 21845960 (CPU Oct2015 Fusion Middleware 10.1.3.5)

$ cd $INST_TOP/ora/10.1.3
$ . xxxx.env                           <== source the env file there
$ echo $ORACLE_HOME       <== make sure it points to 10.1.3 IAS_ORACLE_HOME
/path/to/apps/tech_st/10.1.3

$ unzip p21845960_101350_LINUX.zip
$ export OPATCH_PLATFORM_ID=46         <== need it on 64-bit server
$ cd 21845960
$ opatch napply               <== take about 15 minutes and roll back previously installed CPU patches

Notes:
(1) After 21845960 was applied, "opatch lsinventory | grep 21845960" will show nothing because it is a CPU patch.  But, below line shall show 21845942 (one of the included patches) was installed
$ opatch lsinventory | grep 21845942
(2) Without "export OPATCH_PLATFORM_ID=46" on 64-bit server, opatch exited with error message "NApply failed to apply the following patches "21815758". After that, I tried "opatch napply -skip_duplicate" (I used this option when applied database SPU patch), it says "The input directory could not processed". Then, I went to sub-folder 21815758 and used "opatch apply" to apply it successfully.

3. Patch 21103001
NOTES: This patch replaces CPU Oct2014 Fusion Middleware 10.1.2.3 patch 19434967. See Doc ID 437878.1 CHANGE LOG of Oct 16, 2015.

Start a new OS session or $ . .profile     <== run the main env file
$ echo $ORACLE_HOME      <== make sure it is the 10.1.2 ORACLE HOME
/path/to/apps/tech_st/10.1.2

(1) p14825718_10123_LINUX.zip  (asked by 21103001 README)
   Verify conditions are met to apply Patch  14825718 (Step 3.2 notes of Document 437878.1):
     - 12881480, 13808590, 14041415, 14262118, 14614795, 14577216, 9593176 were NOT applied.
     - 6995251, 7121788 were APPLIED.

$ cd 14825718
$ opatch apply
Note1: README of Bundle Patch is not applicable to E-Business Suite Customers.
Note2: It may rollback some patches. If you get below message, answer "N" to continue:
If you continue, all patches will be rolled back and the new patch (14825718) will be installed.
Do you want to STOP?
Please respond Y|N > N


(2) p6640838_10106_Linux-x86-64.zip  (asked by 21103001 README)
This patch 6640838 only added missing components to OUI 10.1.0.6.0, not install a new OUI
Steps with screenshots: Doc ID 1301320.1 How to patch OUI for installing overlay patches on top of Forms Bundle Patch - 9593176

$ mv $ORACLE_HOME/OPatch $ORACLE_HOME/OPatch.pre_6640838
to reserve the higher version of opatch.

$ cd cd/Disk1/install
$ ./runInstaller -ignoreSysPrereqs

$ cd $ORACLE_HOME
$ mv OPatch OPatch_delete
$ mv OPatch.pre_6640838 OPatch

(3) p8551790_10123_LINUX.zip  (asked by 21103001 README)

$ cd 8551790
$ opatch apply

(4) p21103001_101232_LINUX.zip

$ cd 21103001
$ opatch apply             <== very quick
Note1: Post steps are not needed for EBS. See "Post Steps For Patch 19434967 Files Do Not Exist (Doc ID 1945012.1)"
Note2: If opatch version is older than 1.0.0.0.63, it may give a misleading error message:
The patch directory area must be a number.
ERROR: OPatch failed because of problems in patch area.


4. Run the new adgrants.sql as SYSDBA ( get it from 21507207/admin/adgrants.sql after unzip p21507207_12.1.0_R12_LINUX.zip). Without it, ADFIXUSER.sql will fail.

SQL> @adgrants.sql apps  ( <- lower case)
... ... ...
Start of Creating AD_JAR context
PL/SQL procedure successfully completed.
End of Creating AD_JAR context
Creating PL/SQL Package AD_DBMS_METADATA.
Package created.
Package body created.
End of Creating PL/SQL Package AD_DBMS_METADATA.
Creating PL/SQL Package AD_ZD_SYS
Package created.
Package body created.
End of Creating PL/SQL Package AD_ZD_SYS.
PL/SQL procedure successfully completed.
Commit complete.

5. Check pre-requisites on EBS apps

select * from ad_bugs where bug_number in (
'9239089',    -- R12.AD.B.Delta.3
'19273341',  -- R12.BNE.B.delta.4
'8919491',    -- R12.ATG_PF.B.Delta.3
'18936791',  -- R12.FWK.B.delta.4   see Don ID 1931412.1
'19393542'   -- 12.1.0.2 database patch. It will not show up here :)
);

6. Apply R12.1 Oct2015 CPU 21507207

In my system, I merged 19273341, 18936791, 21507207 together and applied them in one run by adpatch. It may take more than 1 hour on first node (around 18 minutes silence on afprgshrlog.sql !).

Saturday, December 19, 2015

Upgrade R12.1.1 to R12.1.3

I followed Doc ID 1080973.1 in below steps to apply patch 9239090 for upgrading R12.1.1 to R12.1.3 on an Oracle 11.2.0.3.0 database.

Current system status:

SQL> select * from ad_bugs where bug_number in ('9239089', '9239090', '9239095', '9817770', '9966055');
only 9239089 was applied.

$ $IAS_ORACLE_HOME/Apache/Apache/bin/httpd -v
Server version: Oracle-Application-Server-10g/10.1.3.5.0 Oracle-HTTP-Server
Server built:   Jul 21 2009 11:12:22

$ $ORACLE_HOME/bin/frmcmp_batch|grep Forms| grep Version
Forms 10.1 (Form Compiler) Version 10.1.2.3.0 (Production)

$ cat $FORMS_WEB_CONFIG_FILE|grep sun_plugin_version| cut -c 1-35
sun_plugin_version=1.6.0_06

Pre steps in database (to avoid headaches during the upgrading):

1. Setup two database parameters:
_disable_fast_validate=TRUE       <-- this parameter shall be removed after upgrade completed.
pga_aggregate_target=2G

2. Follow Doc ID 1112223.1 to grant XDBADMIN the right role to avoid ORA-31000 error with csrrsreg.sql.
SQL> show user
apps
SQL> select * from USER_ROLE_PRIVS;

USERNAME                       GRANTED_ROLE                   ADM DEF OS_
----------------------------------- ------------------------------------------------- ------- ------ ---
APPS                           AQ_ADMINISTRATOR_ROLE      YES YES NO
APPS                           CTXAPP                                     NO  YES NO
APPS                           JAVASYSPRIV                            NO  YES NO
APPS                           RESOURCE                                NO  YES NO
APPS                           XDBADMIN                                  NO  YES NO

3. Follow Doc ID 1357760.1 & 1081227.1 to avoid autoconfig error from jtfictx.sh
DECLARE
*
ERROR at line 1:
ORA-29874: warning in the execution of ODCIINDEXALTER routine
ORA-29960: line 1,
DRG-10595: ALTER INDEX JTF_AMV_ITEMS_URL_CTX failed
DRG-10758: index owner does not have the privilege to use file or URL datastore
ORA-06512: at "SYS.DBMS_SQL", line 1199
ORA-06512: at line 96

Fixes:
SQL> create role apps_ctx_role;
SQL> grant apps_ctx_role to apps;
SQL> exec ctxsys.ctx_adm.set_parameter('file_access_role', 'apps_ctx_role');
SQL> grant apps_ctx_role to JTF;     -- Grant it to the index owners
SQL> grant apps_ctx_role to AMV;
SQL> grant apps_ctx_role to APPLSYS;
SQL> grant apps_ctx_role to HR;
SQL> grant apps_ctx_role to IBC;
SQL> grant apps_ctx_role to OKC;

4. Follow Doc ID 1551854.1 & 847687.1 to avoid error from EGOSILDU.sql
DECLARE
*
ERROR at line 1:
ORA-02149: Specified partition does not exist
ORA-06512: at line 408


SQL> SELECT ATTR_GROUP_ID
     FROM EGO_FND_DSC_FLX_CTX_EXT WHERE APPLICATION_ID = 431
      AND DESCRIPTIVE_FLEXFIELD_NAME = 'EGO_ITEMMGMT_GROUP'
      AND DESCRIPTIVE_FLEX_CONTEXT_CODE = 'ItemDetailDesc';

ATTR_GROUP_ID
-------------------------
            2

SQL> SELECT 1 FROM EGO_MTL_SY_ITEMS_EXT_TL WHERE ATTR_GROUP_ID = 2
AND ROWNUM = 1;
no rows selected

SQL> SELECT 1 FROM EGO_MTL_SY_ITEMS_EXT_TL WHERE ATTR_GROUP_ID = 2
AND ROWNUM = 1;
no rows selected

Fixes: Open a SR with Oracle Support to get a datafix script from them. And run it as sysdba:
  SQL> @Partition_Fix_Script_Ver2.sql

Notes:   After I used $AD_TOP/sql/adutconf.sql to confirm module EGO is inactive, I let the failed worker to quit and then skipped EGOSILDU.sql in my Dev instance. Seems ignoring the error worked fine.

5. Make sure account OLAPSYS is not locked.
SQL> select username, account_status from dba_users like '%OLAP%';

If locked, it will hit errors in Doc ID 1054417.1:
ERROR at line 1:
ORA-33292: Insufficient permissions to access analytic workspace APPS.ODPCODE
using the specified access mode.
ORA-06512: at "SYS.DBMS_AW", line 67
ORA-06512: at "SYS.DBMS_AW", line 131
ORA-06512: at "SYS.DBMS_AW", line 984
ORA-06512: at "SYS.DBMS_AW", line 937
ORA-33262: Analytic workspace ODPCODE does not exist.     

ORA-06512: at "SYS.DBMS_AW", line 908
ORA-06512: at "APPS.MSD_AW_LOADER", line 10


Pre steps on Apps side:

1. If any schema owner password (such as HR) was changed by Sql*plus abnormally (not by FNDCPASS), the upgrade will fail because adpatch would not have the right password for that module. I had to tell all workers to quit and then "kill" adpatch process on OS level because adpatch kept remembering the bad password. After I used FNDCPASS to change the wrong password, I re-ran adpatch from the beginning and it worked.
2. Apply patch 10257394 (Doc ID 1286779.1) to avoid error with  IEX_SCORE_COMP_DET_U1
(or, copy iexscore.lct from patch .zip file and manually replace the old one)

Apply the patch:

$ unzip 6 .zip files (for patch 9239090) to same folder /path/to/R1213CD
($ unzip xxxX.zip -d /path/to/R1213CD)
$ adadmin   to enable maintenance mode
$ cd /path/to/R1213CD/9239090   <== make folder 9239090 10GB free and rw permissions
$ adpatch                                        <== it takes 3 or more hours
Then, optional step: start apps to do a quick check out.

Post steps:

$ cd 9239095
$ adpatch

$ cd 9817770
$ adpatch

$ cd 9966055
$ adpatch

$ cd $AD_TOP/bin
$ perl admkappsutil.pl       ==> then copy appsutil.zip file to DB server.

$ adconfig.sh on DB tier
$ adautocfg.sh on each apps tiers

disable maintenance mode
start apps services

remove _disable_fast_validate=TRUE

NOTES: In a R12.1.1 instance, a lot of database sessions kept in INACTIVE for a long time (15+ days) and never got closed. So, the number of db sessions increased daily and exceeded easily database parameter PROCESSES (3000). We had to recycle Apps services each two weeks. Modules AR and GL are used most in this instance and most idle sessions are from "e::bes:oracle.apps.icx.security.session.created" by JDBC Thin Client. We tried and did not find a fix to this problem. But, after the instance was upgraded to R12.1.3 and its database was upgraded to 12c, the idle session problem went away surprisingly.

Sunday, December 13, 2015

Configure printer to work with EBS

This summary is not available. Please click here to view the post.

Saturday, December 12, 2015

EBS Refresh

Refresh from EBSPROD (under /u06/app/EBSPROD) to EBSQA (under /u01/app/EBSQA) on a different host in Linux OS.

1. On source nodes, run PERL script. 
$ cd $ADMIN_SCRIPTS_HOME
$ perl adpreclone.pl appsTier        <-- No password is needed
   NOTE: Pre-clone log file located at $INST_TOP/admin/log/StageAppsTier_MMDDHHMM.log

$ cd $COMMON_TOP/clone      <-- to verify new folders are created
$ ls -altr $COMMON_TOP/clone
total 40
drwxr-xr-x  2 applmgr appsuser 4096 Jan 22  2008 html
drwxr-xr-x  3 applmgr appsuser 4096 Jan 22  2008 context
drwxr-xr-x  2 applmgr appsuser 4096 Jan 22  2008 bin
drwxr-xr-x  9 applmgr appsuser 4096 Sep 15  2013 ..
drwxr-xr-x  5 applmgr appsuser  4096 Dec  1 10:06 appsts
drwx------  7 applmgr appsuser  4096 Dec  1 10:07 jre
drwxr-xr-x  3 applmgr appsuser  4096 Dec  1 10:07 oui
drwxr-xr-x  4 applmgr appsuser  4096 Dec  1 10:07 jlib
drwxr-xr-x  5 applmgr appsuser  4096 Dec  1 10:07 appl
drwxr-xr-x 10 applmgr appsuser 4096 Dec  1 10:07 .

Do the same on other source hosts.

2. On target nodes, backup filess
Create a folder, such as /u01/app/admin_scripts/backups, to hold backed-up files. Then run the script backup_4refresh.sh to back up <SID_HOST> specific files.

$ cd admin_scripts/backups
$ ./backup_4refresh.sh

Confirm necessary files are just backed up:
$ ls -al /u01/app/admin_scripts/backups
$ ls -al /u01/app/admin_scripts/backups/admin
$ ls -al /u01/app/admin_scripts/backups/Apache

Optional:  Backup the entire folder to aother partition
$ cd /u01/app
$ tar -zhcvf /u02/app/$CONTEXT_NAME_backup_MMDDYY.tar.gz EBSQA >> backup_MMDD.log

Do the same on other hosts.

3. Make sure all apps services were stopped and database refresh was completed.
Now, remove directories

$ cd /u01/app
$ rm -rf EBSQA
$ rm -rf  oraEBSQAinventory; mkdir  oraEBSQAinventory

4. Copy directories from source node.
    NOTE: copy CM host files to CM host, web/forms host to web/forms host.

$ cd /u01/app
$ rsync --progress -avze ssh applmgr@source_host:/u06/app/EBSPROD /u01/app
   enter password

   sent 12619428 bytes  received 9649138852 bytes  1312649.72 bytes/sec
   total size is 33018009660  speedup is 3.42

It may give warning message:
rsync warning: some files vanished before they could be transferred (code 24) at main.c(1532) [generator=3.0.6]

5. Rename the folder and verify the size
$ cd /u01/app
$ mv EBSPROD EBSQA

$ ls -al EBSQAtotal 16
drwxr-xr-x  4 applmgr appsuser 4096 May  7  2013 .
drwxr-xr-x 16 applmgr appsuser 4096 Apr 15 11:27 ..
drwxr-xr-x  4 applmgr appsuser 4096 May  2  2013 apps
drwxr-xr-x  3 applmgr appsuser 4096 May  2  2013 inst

$cd apps
$ du -ks
31640672       .

$ cd ../inst
$ du -ks
2502420 .

6. Edit /etc/oraInst.loc file to make sure below line is used:

inventory_loc=/u01/app/oraEBSQAInventory

7. Start a new OS session (without running the .env file)

    If you do not modify the .profile, re-login will get message:
    $APPL_TOP/${CONTEXT_NAME}.env: cannot open [No such file or directory]
    Note: by this time, the .env file was deleted when old folder EBSQA was removed in Step 5.
             So env vairables do not exist

8. Go to /u01/app/EBSQA/apps/apps_st/comn/clone/bin    ($COMMON_TOP/clone/bin)
    option: delete old files in /u01/app/EBSQA/apps/apps_st/comn/clone
                $ cd /u01/app/EBS/apps/apps_st/comn/clone
                $ rm -rf jre_BAK_*

   Now, get below answers ready -
   Database Server Node => dbhost1q.domain.com
   database SID => EBSQA
   apps   => appsPWD
   Base Directory =>  /u01/app/EBSQA
   PORT => 1542
   port pool:  21  (1542 -1521)
 
9. Run clone perl script and answer questions
   $ perl adcfgclone.pl appsTier      <<-- run this in CM node first!!
  
++++++++++++++++ answers on CM node ++++++++++++++++
Target System Root Service [disabled] :                <-- for CM node. WEB/Form node will be opposite
Target System Web Entry Point Services [disabled] :
Target System Web Application Services [disabled] :
Target System Batch Processing Services [enabled] :
Target System Other Services [enabled] :               <-- for CM node
Do you want to preserve the Display [y] (y/n)  : n
Target System Display [host1q:0.0] : host1q.domain.com:21.0      <-- OAM will use it for display
Do you want the the target system to have the same port values as the source system (y/n) [y] ? : n
Target System Port Pool [0-99] : 21

++++++++++++++++ answers on Form/Web node ++++++++++++++++
Target System Root Service [enabled] :                       <-- for Form node
Target System Web Entry Point Services [enabled] :
Target System Web Application Services [enabled] :
Target System Batch Processing Services [enabled] : disabled  <-- for Form node
Target System Other Services [enabled] : disabled
Do you want to preserve the Display [xifsapm3q:0.0] (y/n)  : n
Target System Display [host2q:0.0] : host2q.domain.com:21.0   <-- OAM will use it for display
Do you want the the target system to have the same port values as the source system (y/n) [y] ? : n
Target System Port Pool [0-99] : 21

The script may remain silent for a few minutes (or even 40 minutes) on executing $INST_TOP/admin/install/txkWfClone.sql !
(only statement SELECT * from v$session where upper(machine) like 'HOSTNAME%'; can tell if the sql script is running).

Answer "no" - Dot not start apps services after autoconfig completed.

Check the log file. Any more lines than below need your attention or fix:
$ egrep -i 'fail|error|ora-' $INST_TOP/admin/log/ApplyAppsTier_04151536.log
Error while running adlnktools.sh.
ERRORCODE = 0 ERRORCODE_END
ERRORCODE = 0 ERRORCODE_END
AC-50480: Internal error occurred: java.lang.Exception: Error while generating listener.ora.
Error generating tnsnames.ora from the database, temporary tnsnames.ora will be generated using templates
ERRORCODE = 2 ERRORCODE_END
   Result             : FAILED
ERRORCODE = 0 ERRORCODE_END
Unique constraint error (00001) is OK if key already exists
ERRORCODE = 0 ERRORCODE_END

ERRORCODE = 0 ERRORCODE_END
. . .  . . .  . . .

10. Start a new OS session. If necessary, modify the .profile to run .env 
$ . ./.profile

11. Remove obsolete files
$ cd $APPLPTMP    <-- make sure $APPLPTMP points to the right folder!
$ rm -f *.tmp

Note: seems the clone script cleans the folder $APPLTMP automatically.

12. Generate autoconfig file for DBA    (only do this on ONE node)
$ cd $AD_TOP/bin
$ ls -al ad*mk*

$ perl admkappsutil.pl
Starting the generation of appsutil.zip
Log file located at $INST_TOP/admin/log/MakeAppsUtil_04151607.log
output located at $INST_TOP/admin/out/appsutil.zip
MakeAppsUtil completed successfully.

$ cp -p $INST_TOP/admin/out/appsutil.zip $APPLPTMP

13. Verify apps password before email DBA with the password. And clean CM tables
$ sqlplus apps/passwd
SQL> @cmclean.sql
SQL> EXEC FND_CONC_CLONE.SETUP_CLEAN;
SQL> select * from fnd_nodes;    
(This SELECT shell get 0 row returned. After DBA runs adconfig.sh below, it shall have one row.)

Notes: cmclean.sql is an old file but it still works for me in my R12.1.3 instances
REM $Id: cmclean.sql,v 1.4 2001/04/07 15:55:07 pferguso Exp $

14. Ask DBA to run ADCONFIG
$ adconfig.sh contextfile=$ORACLE_HOME/db_ebsqa/appsutil/$CONTEXT_NAME.xml

NOTE: if .xml does not exist on a new instance, generate it first. here is how to generate the .xml file after unzip appsutil.zip on database server :
$ export PERL5LIB=$ORACLE_HOME/appsutil/perl
$ export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$OARCLE_HOME/ctx/lib
$ perl $ORACLE_HOME/appsutil/bin/adbldxml.pl
<enter apps password when prompted>
<enter hostname when prompted>
<enter listener port when prompted>
<enter SID name when prompted>

Output should indicate:
The context file has been created at: $ORACLE_HOME/db_ebsdev/appsutil/EBSDEV_ebsdb1d.xml
(or $ perl adbldxml.pl tier=db appsuser=<APPSuser> )

15. Run script to restore files from backup

$ cd admin_scripts/backups
$ ./resotore_refresh.sh

15. Verify files and make sure two files for site custom
$FND_TOP/fndenv.env
$INST_TOP/ora/10.1.2/forms/server/default.env

Note: two files shall have a section in below format (Otherwise it will be overwritten by autoconfig). Or, modify them after adautocfg.
#Begin Customizations
custom tops
#End Customizations

$ ls -al $INST_TOP/certs/Apache
cwallet.sso  ewallet.p12

17. Update $CONTEXT_FILE

- APPLCSF & APPLPTMP on ALL nodes !
- Below ones are ONLY on Form/Web nodes:
webport
activewebport
login
external_url
webentryhost
webentryurlprotocol

Notes: For real port (not as 443 in F5) when SSL is enabled, make sure the port (such as 4472) for s_active_webport match the port in file ssl.conf and s_webssl_port in $CONTEXT_FILE .

18. Run AD autocfg :  always make CM node work first (after DBA is done with adconfig!)
$ cd $ADMIN_SCRIPTS_HOME
$ ./adautocfg.sh

Optional:  change APPS password using FNDCPASS here, and then run adautocfg.sh again on all nodes.

19. Source .profile to take new env variables after autocfg (or re-login)
$ . ./.profile

20. Start services

21. Login as XML Publisher Admin --> Administration --> General --> replace the path with $APPLPTMP.

22. Update profile "Site%name%"
Check profile option: BNE Debug Log Directory, BNE Upload Staging Directory (then, bounce services)
                                 RRA: Service Prefix (this should be BLANK. Not  hard coded !!)
                                 RRA: Enabled (someones say this must be set to YES. Seems not necessary)
                                 Viewer: Text  (this should be blank or browser)

23. Modify files for customization. Maybe only on the web node. Such as:

- TEMPLATE FILE   : $FND_TOP/admin/template/httpd_conf_1013.tmp
    add a section to it
- TEMPLATE FILE   : $FND_TOP/admin/template/oracle_apache_conf_1013.tmp
   #include "%s_ora_config_home%/10.1.3/Apache/modplsql/conf/plsql.conf"
     include "%s_weboh_oh%/Apache/modplsql/conf/plsql.conf"            <<-- add this line
- Add APPS password to $IAS_ORACLE_HOME/Apache/modplsql/conf/dads.conf

24. Re-create database links, check DBA_DIRECTORIES   (DBA task)

25. Re-link some folders for $CUSTOM_TOP:
$ cd $CUSTOM_TOP/ftp
$ rm in
$ rm out
$ ln -s /path/to/ftp/in in
$ ln -s /path/to/ftp/out out
$ chmod 777 in
$ chmod 777 out

26. Optional: disable production users
-- Doc. ID: 1064798.1.  Disable EBS users   
DECLARE
  -- get user list which should be disabled
  cc number :=0;
  cursor c1 is
  select user_name
     from fnd_user
    where (end_date is null or end_date > sysdate)
                -- access all users that has no end-date or end-date is future
      and (user_name like 'B%' or user_name like 'M%')
      and user_name not in ('SYSADMIN', 'USERVIP1', 'USERVIP2', 'A999999'); -- excluding VIPs
BEGIN
  for c in c1 loop
    -- disable user
    fnd_user_pkg.disableuser(c.user_name);
    cc := cc+1;
    If ( MOD(cc, 50) = 0) then
      commit;
    end if;
  end loop;
  dbms_output.put_line('Totla disabled ' || cc);

  commit;    --commit changes
END;
/

++++++++ Troubleshooting +++++++
1. After CM node is up in the first time, run a CM job got error when opening the log
An error occurred while attempting to establish an Applications File Server connection with the
node FNDFS_CMHOST. There may be a network configuration problem, or the TNS listener
on node FNDFS_CMHOST may not be running. Please contact your system administrator.

you can confirm the problem by running below command on Web Host:

$ tnsping FNDFS_CMHOST
TNS-12547: TNS:lost contact

after host names were deleted by "EXEC FND_CONC_CLONE.SETUP_CLEAN" from database tables and when autoconfig was executed first on Concurrent Host CMhost, web host names are not saved to database tables yet and so tnsnames.ora file on CMhost does not have entries for web hosts.

Fix: two ways to fix it
1). on CM host
(a). Replace tnsnames.ora and sqlnet.ora in $TNS_ADMIN with files from the backup before refresh.
(b). adalnctl.sh stop
(c). adalnctl.sh start
Now, on the Web Host server, "tnsping FNDFS_CMHOST" returns "OK"

2). Run autoconfig AGAIN on all hosts, starting with CM host first.

2. When stopping CM services (to run autoconfig again for the new APPS password), 5 processes on
OS level did not stop. See all five of them in the Concurrent Manager:

CONCURRENT MANAGER                        Actual     Target
Output Post Processor                                     2              0
Workflow Agent Listener Service                     1              0
Workflow Mailer Service                                 1              0
Workflow Document Web Services Service     1              0

I clicked "Terminate" on them, but that did not kill the OS processes. I had to kill them by OS command:

$ kill -12 15524 15529 15544 15548 15555

After I ran autoconfig and started CM services, they showed "Terminted" in GUI Concurrent Manager.
I had to clicked each of them to "Activate" them. They did get started after the clicks !!
Should not try to terminate them in the GUI !!

3. When I ran the autoconfig last on CM node, the login page did not work!!
    So, run autoconfig on web/forms node last.

4. After clone script adcfgclone.pl worked, Autoconfig ended with below error in adconfig.log & ApplyAppsTier_11011132.log:
[CVM Error Report]
The following report lists errors encountered during CVM Phase
      <filename>  <return code where appropriate>
  /u03/app/EBSUAT/apps/apps_st/appl/ad/12.0.0/bin/adgentns.pl  2



Updating s_tnsmode to 'generateTNS'
UpdateContext exited with status: 0
AC-50480: Internal error occurred: java.lang.Exception: Error while generating listener.ora.
Error generating tnsnames.ora from the database, temporary tnsnames.ora will be generated using templates
Instantiating Tools tnsnames.ora
Tools tnsnames.ora instantiated
Web tnsnames.ora instantiated

adgentns.pl exiting with status 2


Fix:  run below line AGAIN
SQL> EXEC FND_CONC_CLONE.SETUP_CLEAN;
Then, run adconfig.sh on DB host. After that, make sure the DB host name shows up in below query before run adautocfg.sh on Apps tiers:
SQL> select * from fnd_nodes;

~~~~~~~~~~~~~~~~~~ script: backup_4refresh.sh ~~~~~~~~~~~~~~~~~~
#!/bin/ksh
# backup files before the refresh   Dec. 2015
cd $HOME/admin_scripts/backups
DT=`date +"%h_%d_%y"`   # backup date

echo It will delete old backup files. Continue ? yes or no
read  answer

case $answer in
  [yY][eE][sS]|[yY])

    if [ -n "$CONTEXT_FILE" ]; then
      echo 'running'
    else
      echo 'environment variable $CONTEXT_FILE does not exit. Exit ...'
      exit 1;
    fi;

    if [ -f $CONTEXT_FILE ]; then
      echo 'starting copy ...'
    else
      echo 'CONTEXT file $CONTEXT_FILE does not exist. Exit ...'
      exit 1;
    fi

    file1=`basename $CONTEXT_FILE`
    if [ -f $file1 ]; then
      mv $file1 $file1'_'$DT   # backup date
    fi
    file2=custom`basename $CONTEXT_FILE .xml`'.env'
    if [ -f $APPL_TOP/$file2 ]; then
      cp -p $APPL_TOP/$file2 .
    fi

    rm -rf Apache admin

    cp -p $CONTEXT_FILE .
    cp -rp $INST_TOP/certs/Apache .
    cp -rp $TNS_ADMIN .
    cp -p $FND_TOP/fndenv.env .
    cp -p $INST_TOP/ora/*2/forms/server/default.env .
    cp -p $APPL_TOP/admin/adkeystore.dat .
    cp -p $APPL_TOP/admin/adsign.txt .
    ## more optional files. Need to manually copy them back if needed
    cp -p $FND_TOP/admin/template/custom/rwbuilder_conf_1012.tmp .
    cp -p $FND_TOP/admin/template/ssl_conf_1013.tmp .
    cp -p $FND_TOP/admin/template/httpd_conf_1013.tmp .
    cp -p $FND_TOP/admin/template/oracle_apache_conf_1013.tmp .
    cp -p $IAS_ORACLE_HOME/Apache/modplsql/conf/dads.conf .
    echo 'Done with backing up files'
    ls -altr $HOME/admin_scripts/backups
    exit 0

   ;;

  [nN][oO]|[nN])
      echo "No"
   ;;

   *)
      echo "Invalid input..."
      exit 1
   ;;
esac
~~~~~~~~~~~~~~~~~~ scripts: restore_refresh.sh ~~~~~~~~~~~~~~~~~~~
#!/bin/ksh
# restore files AFTER clone script during the refresh   Dec. 2015
cd $HOME/admin_scripts/backups
DT=`date +"%h_%d_%y"`

echo It will overwrite some files. Continue? yes or no
read  answer

case $answer in
   [yY][eE][sS]|[yY])

    if [ -n "$CONTEXT_FILE" ]; then
      echo 'running'
    else
      echo 'environment variable $CONTEXT_FILE does not exit. Exit ...'
      exit 1;
    fi;

    file2=custom`basename $CONTEXT_FILE .xml`'.env'
    if [ -f $file2 ]; then
      cp -p $file2 $APPL_TOP/.
    fi

    mv $FND_TOP/fndenv.env $FND_TOP/fndenv.env_clone
    cp -p fndenv.env $FND_TOP/.

    mv $INST_TOP/ora/10.1.2/forms/server/default.env $INST_TOP/ora/10.1.2/forms/server/default.env_clone
    cp -p default.env $INST_TOP/ora/10.1.2/forms/server/.

    mv $INST_TOP/certs/Apache  $INST_TOP/certs/Apache'_'$DT
    cp -pr Apache $INST_TOP/certs/.

    ## files for JRE 1.8. They will be used if Java signing is re-ran. 
    mv $APPL_TOP/admin/adkeystore.dat $APPL_TOP/admin/adkeystore.dat_clone
    cp -p adkeystore.dat $APPL_TOP/admin/.

    mv $APPL_TOP/admin/adsign.txt $APPL_TOP/admin/adsign.txt_clone
    cp -p adsign.txt $APPL_TOP/admin/.

    echo 'Done with restoring files.'

    ;;

  [nN][oO]|[nN])
    echo "No"
    ;;

  *)
    echo "Invalid input..."
    exit 1
    ;;
esac
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The first task of EBS refresh is to refresh the database. Here are the steps:

0. Stop EBS apps
1. In the source database EBSPROD (in 10G and 11G)
1.1 Identify the SCN nmuber for the RMAN script. Check source database backup log to find the sequence.
1.2 SQL> select first_change#, next_change#, first_time from v$log_history
where sequence# = 11047;
2. In the target database EBSQA
2.1 Shutdown the target database
      SQL> alter database backup controlfile to trace;
      SQL> shutdown immediate;
2.2 Drop the databae
      SQL> startup mount restrict;
      SQL> drop database;
2.3 Get ready for the RMAN restore
      SQL> startup nomount;
2.4 Make sure host has enough disk space
2.5 Assume the source database was backed up by RMAN. Run the script
     $ cat db_refresh.sh
      ORACLE_SID=targetDB_ID
      export ORACLE_SID
      export TNS_ADMIN=$ORACLE_HOME/network/admin
      ORACLE_USER=oracle
      NLS_LANG=AMERICAN_AMERICA.AL32UTF8
      NLS_DATE_FORMAT='YYYY-MM-DD hh24:mi:ss'
      export NLS_LANG
      export NLS_DATE_FORMAT
      NB_ORA_CLASS=sourceDBserver
      export NB_ORA_CLASS
      DATE=`date +"%h%d%y_%H%M"`
      rman catalog rman/rmanPWD@rmanDB_ID target sys/PSWD@sourceDB_ID auxiliary / msglog db_refresh.${DATE}.log << EOF
      run {
      ALLOCATE AUXILIARY CHANNEL ch00 TYPE 'SBT_TAPE';
      ALLOCATE AUXILIARY CHANNEL ch01 TYPE 'SBT_TAPE';
      ALLOCATE AUXILIARY CHANNEL ch02 TYPE 'SBT_TAPE';
      SEND 'NB_ORA_CLIENT=sourceDBserver';
      SET NEWNAME FOR TEMPFILE 1 to '/path/to/temp01.dbf';
      SET NEWNAME FOR TEMPFILE 2 to '/path/to/temp02.dbf';
      duplicate target database to targetDB_ID
      UNTIL scn = 5968220384735;
      }
      EOF

      $ ./db_refresh.sh &

3. Bring the database up.
    Do NOT change any password (except SYSTEM).

EBS apps RDA

Two types of RDA on Oracle EBS apps.

1. Data collection test

- Run it for R12.1 from browser (Doc ID 732091.1)
  1. Log onto Oracle E-Business Suite
  2. Click on responsibility Application Diagnostics
  3. Select the Diagnose menu option
  4. Click button Select Application and select an appropriate Application, such as payables (SQLAP), receivables (AR)
  5. Scroll down to group "System Snapshot"
  6. Select test name "RDA"
  7. Input Parameters (* required)
    • Responsibility Id (LOV) *      (seems System Administrator works)
    • Application Shortname (LOV) *  (such as AR, XLA)
    • Mask sensitive data (LOV) *  (seems optional)
    • APPS Schema Username  
    • APPS Schema Password
- Run it by command line (Doc ID 427278.1)

$ cd $IZU_TOP/bin
$ ./rda.sh -vdCRP -e APPL _SHORT='AR' ACT

If getting error "RDA-00001: Cannot change to the output directory", rename the setup.cfg file in the directory and try it again.

2. Download file p20603454_8715310_Linux-x86-64.zip from Oracle support site and install it from unzip. Then
$ cd rda
$ ./rda.sh -T hcve

Monday, November 23, 2015

Run scp or sftp Without a Password

To automate a job for exchanging data files between two servers, it is asked to run it without entering a password by human being.  Assume there are two servers local2d (with users batchdev and batchmgr) and remote1d (with user user01).  Below steps worked on RHEL5. 

A. if a passphase was not entered for "ssh-keygen"
1. on the local server local2d

batchdev@local2d: /u06/app
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/u06/app/.ssh/id_rsa): <Hit enter>   <== option: another path/name
Enter passphrase (empty for no passphrase): <Hit enter>           <== leave it empty
Enter same passphrase again: <Hit enter>
Your identification has been saved in /u06/app/.ssh/id_rsa.
Your public key has been saved in /u06/app/.ssh/id_rsa.pub.
The key fingerprint is:
66:38:f8:65:74:5d:10:88:f9:9a:3e:89:4a:d5:0c:49 batchdev@local2d.domain.com
The key's randomart image is:
+--[ RSA 2048]----+
|      E  o .oo.  |
|     . .o .. .   |
|      o ... .    |
|     . * ..      |
|    . + So       |
|     o *o        |
|    . .o .       |
|   .  . +        |
|    ..   .       |
+-----------------+
Note: If run "$ ssh-keygen -t dsa", it will generate two files with names id_dsa and id_dsa.phb

batchdev@locald2d: /u06/app
$ cd .ssh
$ ls -al
-rw-------  1 batchdev users 1675 Oct 13 11:46 id_rsa
-rw-r--r--  1 batchdev users  410  Oct 13 11:46 id_rsa.pub
-rw-r--r--  1 batchdev users 1622 Aug  6 10:50 known_hosts

2. On the remote server remote1d
$ hostname
remote1d.domain.com
$ whoami
user01

## copy the pub key to remote1d (from server local2d).
$ cd /u04/apps/.ssh
$ scp -p batchdev@local2d:/u06/app/.ssh/id_rsa.pub local2d.key
batchdev@local2d's password: xxxxx

$ mv local2d.key authorized_keys                <== do not overwrite the file!
## Note if the file exists, run "$ cat local2d.key >> authorized_keys"
$ chmod 600 authorized_keys

$ ls -al /u04/app/.ssh
-rw-------  1 user01 users  410    Oct 13 11:46 authorized_keys  
-rw-r--r--  1 user01 users  2087  Mar 30  2015 known_hosts

3. Test SFTP and SSH on local server local2d

batchdev@local2d: /u06/app/  
$ sftp remote1d                             ## batchdev can not get onto it. sftp asks the password.
Connecting to remote1d...
Password:

$ sftp user01@remote1d      ## But login to remote1d as user01 works without a password!
Connecting to remote1d...
sftp> dir -all
-rw-r--r--    1 user01  users     481 Jun 22  2010 .profile
-rw-------    1 user01  users     933 Oct 13 12:35 .sh_history
drwx------   2 user01  users     096 Oct 13 12:27 .ssh
sftp> quit

batchdev@local2d: /u06/app  
$ ssh user01@remote1d            ## ssh to remote1d as user01 also works!
$ hostname
remote1d.domain.com
$ exit

batchdev@local2d: /u06/app
$ scp user01@remote1d:/u04/app/cert.txt .   ## even SCP does not ask for the password
cert.txt                                                   100% 1383     1.4KB/s   00:00 

TROUBLESHOOTING: permission on /u06/app and /u04/app should be 755 or 700. 777 will make passwordless authentication not work. Needs more restrictive.

If it gives below warnings:
$ ssh user01@remote1d
The authenticity of host 'remote1d (167.xx.xx.xxx)' can't be established.
ECDSA key fingerprint is SHA256:r4ofQUP1F8ebW5hWCcCsK7ah...A.
ECDSA key fingerprint is MD5:49:86:cd:21:a3:a4:22:05:68:4a:0e:...:35.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'remote1d' (ECDSA) to the list of known hosts.
Warning: the ECDSA host key for 'remote1d' differs from the key for the IP address '167.xx.xx.xxx'
Offending key for IP in /u06/app/.ssh/known_hosts:20
Are you sure you want to continue connecting (yes/no)? yes

First, answer Yes, and delete line 20 from file /u06/app/.ssh/known_hosts (after doing a backup) on local2d. 
Then, try ssh to login twice. The warning will go away in the 2nd try.

$ ssh user01@remote1d
Warning: Permanently added the ECDSA host key for IP address '167.xx.xx.xxx' to the list of known hosts.

$ ssh user01@remote1d
Now, no more warnings

B. If there is a 2nd user batchMgr on server local2d wants to run sftp into remote1d, additional steps are necessary:
1. Login to local2d server with batchMgr account
2. Create a new directory apps_sftp_key and do a chmod 700 on this directory
3. Copy files id_rsa and id_rsa.pub from ~batchdev/.ssh to apps_sftp_key directory and do a chmod 600 on id_rsa

$ hostname
local2d
$ whoami
batchmgr
$ pwd
/home/batchmgr/apps_sftp_key
$ ls -al
total 16
drwx------  2 batchmgr 1211 4096 Sep 16 14:52 .
drwxrwxr-x 12 batchmgr 1211 4096 Sep 19 12:23 ..
-rw-------  1 batchmgr users 1675 Oct 13 11:46 id_rsa
-rw-r--r--  1 batchmgr users  410  Oct 13 11:46 id_rsa.pub 

One line to run SFTP without interactive:

batchmgr@locald2d: $ sftp -oport=22 -b sftp.ctl -oIdentityFile=~batchmgr/apps_sftp_key/id_rsa user01@remote1d:/apps/local/ftp/in 
Changing to: /apps/local/ftp/in
sftp> put /home/batchmgr/temp/test.del test.del
Uploading /home/batchmgr/temp/test.del to /apps/local/ftp/in/test.del
sftp> version

SFTP protocol 3
sftp> quit

Here, sftp.ctl is a command file in the current directory:
$ more sftp.ctl
put /home/batchmgr/temp/test.del test.del
version
quit 

C. If a passphrase was entered for "ssh-keygen"

$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/u06/app/.ssh/id_rsa): <Hit enter>
Enter passphrase (empty for no passphrase):    <== "welcome01" works, but "welcome" not
Enter same passphrase again:<Enter your passphrase again>   <== welcome01

Additional steps on ssh agent are needed on the local2d to make it work:

batchdev@local2d: /u06/app
$ echo $SHELL
/usr/bin/ksh
$ ssh-agent $SHELL
$ ps -ef | grep ssh-agent
  batchdev 118621 174327   0 17:32:17       -   0:00 ssh-agent /usr/bin/ksh
  batchdev 161219 174327   0 17:32:28  pts/0  0:00 grep ssh-agent

$ ssh-add
Enter passphrase for /u06/app/.ssh/id_rsa: welcome01
Identity added: /u06/app/.ssh/id_rsa (/u06/app/.ssh/id_rsa)

Now, sftp, ssh and scp shall work without a password or a passphase.

Saturday, November 7, 2015

EBS R12.1 patching for JRE 1.8

To make EBS R12.1.3 work with JRE (Java Run-time Environment) 1.8, patches on apps and both ORACLE_HOMEs are needed. The main document is ID 393931.1 "Deploying JRE (Native Plug-in) for Windows Clients in Oracle E-Business Suite Release 12". I do not see this activity requires any database patches. My databases are in 11.2.0.2 or above.

1. Verify the versions and conditions
  (1) $ $IAS_ORACLE_HOME/Apache/Apache/bin/httpd -v
  Server version: Oracle-Application-Server-10g/10.1.3.5.0 Oracle-HTTP-Server
  Server built:   May 16 2013 15:47:41

  (2) $ $ORACLE_HOME/bin/frmcmp_batch|grep Forms| grep Version
  Forms 10.1 (Form Compiler) Version 10.1.2.3.0 (Production)
  (Because 10.1.2.3.0 patch 5983622 was was installed by Installer, how to confirm it is installed?)

  (3) Confirm first 3 patches were installed
  select * from ad_bugs where bug_number in
  ('4377566',  -- Step 2.1, 393931.1
  '8919489',   -- Step 2.3.2, 437878.1
  '14837539', -- Step 2.1.1 & Step 3.8, 437878.1
  '11776182' ); -- Step 2.1.2 Footnote7, 437878.1. very old? Skip it

2. Patch in 10.1.3 ORACLE_HOME ( Section 1)

Shutdown apps services (adstpall.sh apps/appsPWD) on all nodes and complete a backup.

Apply patch 19568561 (required):
  $ cd $INST_TOP/ora/10.1.3
  $ . xxxx_XXX.env               <== change the ORACLE_HOME to 10.1.3
  $ echo $ORACLE_HOME 
     /u02/app/EBSDev/apps/tech_st/10.1.3        <==  make sure it is 10.1.3!

  $ export OPATCH_PLATFORM_ID=46
     (to avoid error on 64-bit Linux:
     OPatch detects your platform as 226 while this patch 19568561 supports platforms: 46 Linux Intel)
  $ cd 19568561
  $ opatch apply

Update on 12/19/2015: Document 393931.1 was updated recently with recommendation of replacing this patch 19568561 with October 2015 CUP patch 21845960. I found patch 21845960 worked better and fixes issue with Firefox (version 43.0+).

3. Patches in 10.1.2 ORACLE_HOME (OracleAS 10g Patches. Follow Doc ID 437878.1
Start a new OS session, or $ . .profile
$ echo $ORACLE_HOME
   /u02/app/EBSDev/apps/tech_st/10.1.2      <== make sure it is 10.1.2

(1) p14825718_10105_LINUX.zip     (MLR patch or Bundle Patch. It is pre-requisite for patch 21103001 )
     Verify conditions are met to apply Patch 14825718 (Step 3.2 notes of Document 437878.1):
     12881480, 13808590, 14041415, 14262118, 14614795, 14577216, 9593176 were NOT applied
     while 6995251, 7121788 were APPLIED

$ cd 14825718
$ opatch apply

NOTES: It will roll back some patches that were previously applied. Accept that and do NOT stop it.
The patch's README is not applicable to E-Business Suite. Step 5 in below covers it after all Forms patches are applied. 

Install any patches that miss from the list of Step 2.1.2 in 10.1.2 ORACLE_HOME. I had to catch up 14 patches (well, even the document 437878.1 does not say "required").

(2) p6640838_10106_Linux-x86-64.zip     <== pre-requisite for patch 21103001
This patch 6640838 only adds missing components to OUI 10.1.0.6.0, and does not install a new OUI.
Installation steps with screenshots: How to patch OUI for installing overlay patches on top of Forms Bundle Patch - 9593176 (Doc ID 1301320.1)

$ mv $ORACLE_HOME/OPatch $ORACLE_HOME/OPatch.pre_6640838
to reserve the higher version of opatch.
$ export DISPLAY=xxx.xx.xxxx:0.0

$ cd cd/Disk1/install

$ Modify file oraparam.ini to include Linux 5     <== need this workaround on RHEL5
                    Linux=redhat-2.1AS,redhat-3,redhat-4,redhat-5
$ ./runInstaller
or
$ ./runInstaller -ignoreSysPrereqs   ==> follow Doc ID 1301320.1 to the finish line!

$ cd $ORACLE_HOME
$ mv OPatch OPatch_delete
$ mv OPatch.pre_6640838 OPatch

(3) p8551790_10123_LINUX.zip            <== pre-requisite for patch 21103001

$ cd 8551790
$ opatch apply

(4) p21103001_101232_LINUX.zip
 This patch replaces 19434967
 Pre-requisite: OUI componetes (patch 6640838) and patch 8551790.  Also references:    
        Post Steps For Patch 19434967 Files Do Not Exist (Doc ID 1945012.1)
        Font Changes In EBS Forms After Application Of CPU Patches (Doc ID 2005998.1)
Notes: if opatch version is lower than 1.0.0.0.63, it may give a misleading error: the patch directory 21103301 doesn't match the patch id.

Updates in June 2016: patch 21103001 is replaced by MLR patch 22698265 after JRE 1.8.0_92 was released (see Change Log of Doc 437878.1 and Doc. 393931.1). During the installation of patch 22698265, it will rollback patch 21103001 if it was applied. It has the same pre-requisites as 21103001 does.

$ cd 21103001
$ opatch apply

(5) p10152652_10123_LINUX.zip

pre-requisite: patch 7121788. Yes
verify: $ chmod +x $ORACLE_HOME/bin/genshlib

$ cd 10152652
$ opatch apply
$ sh ./patch.sh
... ... ... ... 
I skipped RSF (required support files) patches in Step 3.4 (and Step 3.5), because my database is in 11.2.0.2 and those patches seem for database 10g.

4. Apply EBS R12.1 Forms Interoperability Patch (Step 2.1.1, Step 3.8 of Doc ID 437878.1)

 SQL> select * from ad_bugs where bug_number = '14837539';  -- to confirm it was not installed yet

 $ adadmin    to enable maintenance mode
 $ cd 14837539
 $ adpatch

5. Post AS10g patching steps (Section 4 of Doc ID 437878.1)

$ cd $ORACLE_HOME/forms/lib
$ make -f ins_forms.mk install

$ cd $ORACLE_HOME/reports/lib
$ make -f ins_reports.mk install

$ adadmin
    ==> 1 Select Generate Applications Files
    ==> 4 Generate Product JAR Files  (No  - Do not opt to force the regeneration of all JAR files)

optional: verify the versions.
$ export DISPLAY=XXX.XXX.XXX:0.0
$ ORACLE_HOME/bin/frmcmp help=y
$ ORACLE_HOME/bin/rwrun ?|grep Release

UPDATES:
I highly recommend to run "adstrtal.sh" to start all services and check out web login and forms. At this time point, the startup script may deploy new EAR file. If any failure, you know it is not caused by new JRE version of next steps.

I had one instance that failed to launch forms after Step 10. There was a Time out error in adstrtal.log on "adformsctl.sh start" to deploy formsapp.ear file. After I recycled all services, adopmnctl.sh showed "OC4J: forms" status got changed from DOWN to ALIVE. But, GUI forms was still not popup. It took me many hours to find that the problem was not from the new JRE version. Actually, after I re-ran Step 10, I was able to launch EBS forms even though the errors from EAR deployment never got fixed.

6.  Apply the JRE Interoperability Patch 21624242:R12.TXK.B (Step 2.1). Now follow Doc ID 393931.1
SQL> select * from ad_bugs where bug_number = '4377566'; --confirm pre-patch 4377566 was applied

$ mv $FND_TOP/bin/txkSetPlugin.sh $FND_TOP/bin/txkSetPlugin-4377566.sh
$ cd 21624242
$ adpatch

7. AD Patch 17191279 - Enhanced Jar Signing for Oracle E-Business Suite (Doc ID 1591073.1)

(as sysdba) SQL> @adgrants.sql apps
Note: This script may give errors from dropping some objects. Ignore them.
If a newer version of adgrants.sql (e.g. the one by Oct 2015 CPU patch) has been executed before, this step can be skipped.

$ cd 17191279
$ adpatch

8. AD Patch 18312333 (see Doc ID 1591073.1)

$ cd 18312333
$ adpatch

9. Download JRE file (Step 2.2)
   Click on the hype link " JRE Parameter Settings " (in Step 2.2) to get the information table in
   Appendix D: Reference Information of this document.
  
   Patch 21045690: Oracle JDK 8 Update 51
     selected and downloaded this Window one for both Windows (32-bit) and Windows x64 (64-bit),
     although my EBS hosts use Linux OS:
     jre-8u51-windows-i586.exe     <== In Oct. 2015 I downloaded this latest one (32-bit)

   (or, http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html)
 
$ cp -p jre-8u51-windows-i586.exe $COMMON_TOP/webapps/oacore/util/jinitiator/j2se18051.exe
  
10. Run script on web tier only (Section 3 of Doc ID 393931.1 )
The document says "Run the $FND_TOP/bin/txkSetPlugin.sh script against the web node". But I did not meet problem after running it on CM node also.

 $ $FND_TOP/bin/txkSetPlugin.sh 18051
... ... ...
Updating XML context file with new J2SE parameters...
Updated J2SE plugin to jdk
Updated J2SE Version to 1.8.0_051
Updated J2SE Classid to CAFEEFAC-0018-0000-0051-ABCDEFFEDCBA

AutoConfig is configuring the Applications environment ... ...

If success, two variables shall get new values in $CONTEXT_FILE:
$ grep sun $CONTEXT_FILE
    <sun_plugin_ver oa_var="s_sun_plugin_ver">1.8.0_051</sun_plugin_ver>
    <sun_plugin_type oa_var="s_sun_plugin_type">jdk</sun_plugin_type>
    <sun_clsid oa_var="s_sun_clsid">CAFEEFAC-0018-0000-0051-ABCDEFFEDCBA</sun_clsid>

$ cat $FORMS_WEB_CONFIG_FILE|grep sun_plugin_version| cut -c 1-35      (see Doc. 468311.1)
sun_plugin_version=1.8.0_051

UPDATES in January 2016: after newer JRE 1.8.0_66 version became available, I downloaded it from patch 22286087 and ran below lines, instead. All worked the same as JRE 1.8.0_51 on both server and user's client.
$ cp -p jre-8u66-windows-i586.exe $COMMON_TOP/webapps/oacore/util/jinitiator/j2se18066.exe
$ $FND_TOP/bin/txkSetPlugin.sh 18066

11. Start apps services
 $ adadmin    to disable maintenance mode
 $ adstrtal.sh apps/PW
12. On client workstation's Java Console, add the URL (https://sitename.domain.com) to Exception list on Security tab. Without this, forms will get " Application Blocked by Java Security " popup.

Now, the EBS Forms shall fire up on a workstation where JRE 1.8.0_51 was installed (with 2 or 3 annoying popups).

TROUBLESHOOTING:

If the forms link has no response or Forms do not show up after clicks, clean Java cache and IE cache on the client machine before re-trying it. You may try it in Firefox and if you get " 404 Not Found  The requested URL /forms/frmservlet was not found on this server. " error, there might be a problem with EAR file deployment. Scary part! Workarounds: (a) Stop all services cleanly and try startup adstrtal.sh again. (b) In some of my cases, I had to re-run Step 5 or Step 10 to get forms fired up. (c) Manually deploy EAR file.

Normally, just keep all default options under Java Console. If Java Console log shows timed out or failure error, test some options under Advanced tab in Java. Also, on IE Tools => Manage add-ons, click the dropdown under Show (on the left) to select "All adds-on", then make sure Java add-ons are "Enabled". You shall see below similar two (or more):






NOTES:
(1). In some environment, users may not have permission to install software on their workstation. JRE 1.8.0_51+ (32-bit) shall have been installed on PC by Windows Admin before users can launch EBS Forms.
(2). Make sure TLS1.x is enabled. If TLS1.x is not enabled, enable it first. Otherwise, EBS Forms may not launch after JRE1.8 patches are applied.
(3). If users' client has higher than 1.8.0_51 (such as JRE 1.8.0_66) installed, EBS Forms will still work with the higher JRE class (with a couple of popups for confirmation). But it will not work with JRE 1.9.0_xx (a higher JRE family in the future).

Post steps:
Follow Doc ID 1591073.1 on Java signing (to get rid of Step 12 above).


Sunday, November 1, 2015

Find the version of executable file and database package

1. When see below lines in request log, SQL statement could be used to find the executable name.
    -----------------------------------------------------------------------------
    Copyright (c) 1979, 1999, Oracle Corporation. All rights reserved.
    MSCPLD module: Loader Worker With Direct Load Option
    +---------------------------------------------------------------------------+

Step1
SQL> select EXECUTABLE_NAME,EXECUTION_FILE_NAME,EXECUTION_FILE_PATH
 from fnd_executables
 where EXECUTABLE_NAME like '%MSCPLD%';

EXECUTABLE_NAME    EXECUTION_FILE_NAME        EXECUTION_FILE_PATH
MSCPLD                          MSCPLD.sh   

Step 2. Then, use "locate" to find the file:
$ locate MSCPLD.sh
 /u02/app/EBSDEV/apps/apps_st/appl/msc/12.0.0/bin/MSCPLD.sh

2. How to get the header file versions of all the header files for an executable in Unix

Example 1
$ cd $AP_TOP/bin
$ strings -a APXXTR |grep Header

Example 2, ARRGTA file:
$ strings -a $AR_TOP/bin/ARRGTA | grep '$Header'

SELECT /* $Header: fdffvs.lc 120.17.12010000.8 2010/05/07 22:42:10 tebarnes ship $ */ event_code, user_exit FROM fnd_flex_validation_events WHERE flex_value_set_id = :id ORDER BY event_code
SELECT /* $Header: fdffvs.lc 120.17.12010000.8 2010/05/07 22:42:10 tebarnes ship $ */ additional_where_clause FROM fnd_flex_validation_tables WHERE flex_value_set_id = :id
$Header: arrgta.opc 120.9 2006/06/27 17:16:49 rkader ship $
$Header: arjbal.lpc 120.2 2005/10/24 14:13:01 srivasud ship $
$Header: arjigl.lpc 120.18.12010000.6 2009/10/05 20:43:34 mraymond ship $
 .......

Notes: "strings" can also get Java file's version:
$ strings -a $JAVA_TOP/oracle/apps/frm/xdo/bne/utilities/FrmUploadModule.class |grep '$Header'
S$Header: FrmUploadModule.java 120.2.12010000.16 2014/05/09 05:25:46 jsiripur ship $

3. Use below statement to get database package version applied to the database:
SQL> select * from dba_source where name='XXXXX' and line=2;
Example:
select text from dba_source where name='AP_ACCTG_DATA_FIX_PKG' and line=2;
TEXT
/* $Header: apgdfals.pls 120.1.12010000.21 2013/09/05 13:06:08 pshivara ship $ */
/* $Header: apgdfalb.pls 120.1.12010000.68 2013/10/24 11:27:22 rseeta ship $ */

To check the code file version on file system, use
$ grep -i Header $AP_TOP/patch/115/sql/apgdfalb.pls

NOTE1: EBS utility adident (in unix, windows and other OS) can also be used to provide the file versions.
NOTE2: Before applying a patch, you may check if there a higher version of file in other patches:
How to find the Latest/Newest Version of an Oracle Receivables File (Doc ID 1584999.1)

    Blank log or error "Function ncrorou returned error code 3010"

    When trying to open the log or output files from EBS R12.1 Forms, suddenly get a totally blank html page or below error:

    An error occurred while attempting to receive the output arguments of the remote procedure. Function ncrorou returned error code 3010. The Applications File Server process may have exited abnormally. Please contact your system administrator

    I found the cause can be bad Temp tablespace in the database, over-size log file, or no disk space left in somewhere on the server.

    Saturday, October 3, 2015

    Concurrent jobs that should run periodically

    In a production environment, some concurrent jobs are necessary to keep the system running smoothly. Below list covers good candidates.

    USER_CONCURRENT_PROGRAM_NAME        CONCURRENT_PROGRAM_NAME
    Workflow Background Process                               FNDWFBG
    Workflow Control Queue Cleanup                            FNDWFBES_CONTROL_QUEUE_CLEANU
    Workflow Directory Services User/Role Validation     FNDWFDSURV
    Purge Obsolete Workflow Runtime Data                  FNDWFPR
    Purge Concurrent Request and/or Manager Data      FNDCPPUR (one on request logs)
    Purge Concurrent Request and/or Manager Data      FNDCPPUR (one on manager logs)
    Delete Diagnostic Statistics                                   DELDIAGSTAT
    Purge Logs and Closed System Alerts                    FNDLGPRG
    Purge Inactive Sessions                                    FNDDLTMP (delete data from table ICX_SESSIONS)
    Request Set Gather Statistics Schemas (weekly run)  Gather Schema Statistics

    One of the important ones is to collect statistics. A Request Set can be created for that by
    Requests => Set => name it "Gather Statistics Schemas (weekly run)"
    Then, Define Stages => Requests =>
    Enter a Seq number and select seeded Program "Gather Schema Statistics" for each schema (AR, GL, XLA, APPS, APPLSYS, ...). Make sure the Owner is sysadmin, otherwise sysadmin may be unable to see it. If the parallel Degree 16 is not specified, it will take the default from the database (I saw 32 in a run).


    If job "Purge Concurrent Request and/or Manager Data" is not scheduled to run regularly, table fnd_env_context may become very big. You may have to truncate the table as the only option of reducing its size.

    References:
    - What Are Concurrent Reports That Should Be Scheduled Periodically [ID 1066117.1] .
    - Why is The "Purge Inactive Sessions" Concurrent Program Not Deleting Records From ICX_SESSIONS? [ID 1073768.1].

    Below query find all scheduled concurrent requests (or CM requests scheduled by a user):

    SELECT
        fr.responsibility_key responsibility,
        fcp.concurrent_program_name,
        fcpt.user_concurrent_program_name,
        decode(fcr.status_code,
            'A', 'Waiting',
            'B', 'Resuming',
            'C', 'Normal',
            'D', 'Cancelled',
            'E', 'Error',
            'F', 'Scheduled',
            'G', 'Warning',
            'H', 'On Hold',
            'I', 'Normal',
            'M', 'No Manager',
            'Q', 'Standby',
            'R', 'Normal',
            'S', 'Suspended',
            'T', 'Terminating',
            'U', 'Disabled',
            'W', 'Paused',
            'X', 'Terminated',
            'Z', 'Waiting') status,
        decode(fcr.phase_code,
            'C', 'Completed',
            'I', 'Inactive',
            'P', 'Pending',
            'R', 'Running') phase,
        fcr.request_id,
        fcr.parent_request_id,
        fu.user_name requestor,
        to_char(fcr.requested_start_date, 'MON-DD-YYYY HH24:MM:SS') START_DATE,
        fcr.completion_text
    FROM
        fnd_concurrent_requests fcr,
        fnd_concurrent_programs fcp,
        fnd_concurrent_programs_tl fcpt,
        fnd_user fu,
        fnd_responsibility fr
    WHERE
        --fcr.status_code in ('Q', 'I') and
        --fcr.hold_flag = 'N' and
        fcr.requested_start_date > sysdate and
        fu.user_id = fcr.requested_by and
        fcr.concurrent_program_id = fcp.concurrent_program_id and
        fcr.concurrent_program_id = fcpt.concurrent_program_id and
        fcr.responsibility_id = fr.responsibility_id
        -- and fu.user_name = 'UserName'
    order by fcr.requested_start_date,  fcr.request_id;

    SQL scripts show R12 Profile Options

    Below query will find the value on Profile option(s). It is modified from a script in Doc ID 1159313.1 "Unable To Authenticate Session Error When Login to Different R12 Instance in Same IE Session". Exact profile name is in table fnd_profile_options_tl .

    SELECT p.profile_option_name, fpot.user_profile_option_name NAME,
    decode(v.level_id,
                 10001,'SITE',
                 10002, (select 'App:'||a.application_short_name
                                from fnd_application a
                              where a.application_id = v.level_value),
                 10003, (select 'Resp:'||f.RESPONSIBILITY_KEY
                                from fnd_responsibility f
                              where f.responsibility_id = v.level_value),
                 10004, (select 'User:'||u.user_name
                                from fnd_user u
                              where u.user_id = v.level_value),
                 10005, (select 'Server:'||n.node_name
                                from fnd_nodes n
                              where n.node_id = v.level_value),
                 10006, (select 'Org:'|| o.name
                                from hr_operating_units o
                              where o.organization_id = v.level_value),
                 'NOT SET') PROF_LEVEL,
                  nvl(v.profile_option_value,'NOT SET') profile_option_value, fpot.description
    FROM
      fnd_profile_options p,
      fnd_profile_option_values v,
      fnd_profile_options_tl fpot
    WHERE
    p.profile_option_id = v.profile_option_id (+)
    and p.application_id = v.application_id (+)
    and p.profile_option_name = fpot.profile_option_name
    -- and p.profile_option_name = 'FND_DIAGNOSTICS'
    -- and fpot.user_profile_option_name like 'FND: D%'
    and fpot.user_profile_option_name like 'Signon%'
    order by 1, v.level_id;

    A query to find ALL profile Option values (modified from a script in Doc ID 2026081.1):

    select n.user_profile_option_name NAME,
           decode(v.level_id,
                   10001, 'Site',
                   10002, 'Application',
                   10003, 'Responsibility',
                   10004, 'User',
                   10005, 'Server',
                   10006, 'Organization',
                   10007, 'ServResp',
                   'UnDef') LEVEL_SET,
           decode(to_char(v.level_id),
                  '10001', '',
                  '10002', app.application_short_name,
                  '10003', rsp.responsibility_key,
                  '10004', usr.user_name,
                  '10005', svr.node_name,
                  '10006', org.name,
                  '10007', 'depends=',
                  v.level_id) "CONTEXT",
           v.profile_option_value VALUE,
           (select n.node_name
              from
                   fnd_nodes n
             where
                   n.node_id=level_value2) Server,
                   decode(v.LEVEL_VALUE,
                   -1, 'Default',
                   rsp.responsibility_key) Resp,
                   decode(LEVEL_VALUE_APPLICATION_ID,
                   -1, 'Default',
                   app.application_short_name) Application
      from fnd_profile_options p,
           fnd_profile_option_values v,
           fnd_profile_options_tl n,
           fnd_user usr,
           fnd_application app,
           fnd_responsibility rsp,
           fnd_nodes svr,
           hr_operating_units org
     where p.profile_option_id = v.profile_option_id (+)
       and p.profile_option_name = n.profile_option_name
      -- and (upper(v.profile_option_value) like '%HTTP%')   -- if you want to find the value, enable this line
      -- and p.profile_option_name like 'APPLICATIONS_HOME%'   -- if you want to find the name
       and    usr.user_id (+) = v.level_value
       and    rsp.application_id (+) = v.level_value_application_id
       and    rsp.responsibility_id (+) = v.level_value
       and    app.application_id (+) = v.level_value
       and    svr.node_id (+) = v.level_value
       and    org.organization_id (+) = v.level_value
     order by name, level_set;

    A change in Profile option can make the EBS run very differently. Below script will find Profile options that were change within one day.

     SELECT '''' || a.user_profile_option_name
           || ''' Was Updated with value '
           || b.profile_option_value mesg,
           (SELECT user_name
                 FROM apps.fnd_user u
                WHERE u.user_id = b.last_updated_by) who , b.last_update_date, b.level_value
      FROM apps.fnd_profile_options_vl a,
           apps.fnd_profile_option_values b,
           apps.fnd_user c
     WHERE a.profile_option_id = b.profile_option_id
       AND b.last_updated_by = c.user_id
       AND (   b.last_update_date > SYSDATE - 1   -- <- put a different number here if needed
            OR b.creation_date > SYSDATE - 1
           );
    NOTE: Not sure why, but this query is not accurate sometimes (when the value was changed to null).

    Clean Java cache

    Sometimes, changes to Profile options do not take effect until Apache server is bounced. This delay may be due to Java Caching.  Java caching provides a powerful, flexible, easy to use mechanism for storing database results and other Java objects in-memory for repeated usage, thereby improving application performance.

    Steps for cleaning Java cache (do NOT do it in a busy production system):

    1. Log into EBS with the Functional Administrator responsibility
    2. Choose the Core Services Tab => Caching Framework Sub-Menu
    3. Proceed to choose 'Global Configuration' from the left hand side menu that appears
    4. In the far right choose 'Clear all Cache' button

    Oracle documents on EBS Caching:

    1. Note 759038.1 How To Clear The Cache Using Functional Administrator?
    2. Note 455194.1 Diagnosing database invalidation issues with Java Cache for eBusiness Suite
    3. Note 742107.1 How To Clear Caches (Apache/iAS, Modplsql, Browser, Jinitiator, Java, Portal, WebADI) for E-Business Suite?
    4. Note 275879.1 Oracle Applications Java Caching Framework Developer’s Guide Release 11i

    Friday, September 25, 2015

    Error messages on EBS Forms

    1. "XXXX is not a valid responsibility for the current user. Please contact your System Administrator."

    - First possibility is that this responsibility has an End date for this user. Check user's account.

    - After adding a responsibility to a user, the user may receive above message. And the attached responsibility may not appear in the Home Page until the Apache is bounced.

    One solution could be to clear the cache:
    Navigate to Functional administrator > Core Service > Caching Framework > Global Configuration > Clear All Cache

    Another place to check:
    Search for profile 'Applications Start Page'. Delete the value set at user level (if any).

    Also make sure Workflow Service Components are up and running (OAM -> Workflow Manager (dropdown) -> Service Components):
       . Workflow Deferred Agent Listener
       . Workflow Java Deferred Agent Listener

    2. "Function not available to this responsibility. Change responsibilities or contact System Administrator"

    - If it is on a custom form, make sure its path CUSTOM_TOP is added to $INST_TOP/ora/10.1.2/forms/server/default.env file.

    - Use submenu item Help --> Diagnostics --> Examine.  Then, click the "Examine Fields and variable values" to troubleshoot. Reference Doc ID 1079951.1.

    - If this message shows in R12.1.3 while trying to access Help --> Diagnostics, change the profile "Utilities:Diagnostics" to Yes at user or responsibility level. Please see Doc ID 1200743.1.

    3.  If  R12.1 "adformsctl.sh start" gets error, check logs:

    $LOG_HOME/ora/10.1.3/j2ee/forms/forms_default_group_1/application.log
    $LOG_HOME/ora/10.1.3/j2ee/oacore/oacore_default_group_1/application.log

    When the Form service is starting, it checks whether latest formsapp.ear is deployed. If it finds a newer version, Form service will take longer to start and say message:
    ==========================================
    *** Latest formsapp.ear has NOT been deployed ***
    Deploying the latest EAR file...
    ==========================================
    See DocID 1210660.1 (Forms Startup Script adformsctl.sh Shows Deployment Message While Starting Forms Services).

    4.  How to deploy Forms EAR (Enterprise ARchive) file, such as formsapp.ear (under $ORACLE_HOME/forms/j2ee) ?

    DocID 397174.1 (Deploying a New EAR File in Oracle Applications Release 12) gives two key steps:
    1) Edit file (with a temp password) - $INST_TOP/ora/10.1.3/j2ee/forms/config/system-jazn-data.xml
    2) Run deployment - $FND_TOP/bin/txkrun.pl -script=CfgOC4JApp
        (if all work, it shall say "No error encountered." at the end)

    DocID 1945012.1 also gives a way to manually deploy formsapp.ear (for Oracle Forms ?? vs Oracle EBS R12). But I never try it:
    $ dcmctl redeployApplication -f $ORACLE_HOME/forms/j2ee/formsapp.ear -a formsapp -co OC4J_BI_Forms