Saturday, May 21, 2016

Oracle: CREDENTIAL: ORA-27369: job of type EXECUTABLE failed with exit code: 7 !@#--!@#7#@!--#@!&

This issue is caused by incorrect user being used during dbms_scheduler credential setup.  The exit code of 7 is basically referring to permission issue. Pre-requisite should make sure the jssu, externaljob.ora and extjob have correct permission setup.

Note: there are 2 ways to create scheduler credential. DBMS_SCHEDULER.CREATE_CREDENTIAL is deprecating in 12.1 and preferably be using DBMS_CREDENTIAL.CREATE_CREDENTIAL package 12.1 onward.

Setup: 
Legit OS level user: oracle and password is vmware
Instance level user setup: scott
ascript.sh is a script that is calling another sql script at the OS level.




TEST # 1 : dbms_scheduler with valid OS user - PASSED

exec dbms_scheduler.create_credential('EXT_JOB_CRED1', 'oracle', 'vmware');

exec dbms_scheduler.drop_job ('scott.SCRIPT_JOB1');

exec dbms_scheduler.create_job ( job_name => 'SCRIPT_JOB1', job_type => 'EXECUTABLE', job_action => '/home/oracle/Downloads/script/ascript.sh', start_date => SYSTIMESTAMP, repeat_interval => 'freq=hourly;interval=2', end_date => NULL,enabled => TRUE,auto_drop => FALSE,comments => 'Executable jobfor ascript.sh',credential_name => 'scott.EXT_JOB_CRED1');

EXEC dbms_scheduler.run_job('SCRIPT_JOB1');

SQL> EXEC dbms_scheduler.run_job('SCRIPT_JOB1');

PL/SQL procedure successfully completed.


TEST 2: DBMS Scheduler with random user - FAILED

exec dbms_scheduler.create_credential('EXT_JOB_CRED2', 'somerandomuser', 'vmware123');

exec dbms_scheduler.drop_job ('scott.SCRIPT_JOB2');

exec dbms_scheduler.create_job ( job_name => 'SCRIPT_JOB2', job_type => 'EXECUTABLE', job_action => '/home/oracle/Downloads/script/ascript.sh', start_date => SYSTIMESTAMP, repeat_interval => 'freq=hourly;interval=2', end_date => NULL,enabled => TRUE,auto_drop => FALSE,comments => 'Executable jobfor ascript.sh',credential_name => 'scott.EXT_JOB_CRED9');
EXEC dbms_scheduler.run_job('SCRIPT_JOB2');

SQL> EXEC dbms_scheduler.run_job('SCRIPT_JOB2');
BEGIN dbms_scheduler.run_job('SCRIPT_JOB2'); END;

*
ERROR at line 1:
ORA-27369: job of type EXECUTABLE failed with exit code: 7 !@#--!@#7#@!--#@!&
ORA-06512: at "SYS.DBMS_ISCHED", line 209
ORA-06512: at "SYS.DBMS_SCHEDULER", line 594
ORA-06512: at line 1

Test 3 – using DBMS_CREDENTIAL with random user - FAILED

 exec DBMS_CREDENTIAL.CREATE_CREDENTIAL ('EXT_JOB_CRED3', 'randomuser', 'vmware123');

exec dbms_scheduler.create_job ( job_name => 'SCRIPT_JOB3', job_type => 'EXECUTABLE', job_action => '/home/oracle/Downloads/script/ascript.sh', start_date => SYSTIMESTAMP, repeat_interval => 'freq=hourly;interval=2', end_date => NULL,enabled => TRUE,auto_drop => FALSE,comments => 'Executable jobfor ascript.sh',credential_name => 'scott.EXT_JOB_CRED10');
EXEC dbms_scheduler.run_job('SCRIPT_JOB3');

SQL> EXEC dbms_scheduler.run_job('SCRIPT_JOB3');BEGIN dbms_scheduler.run_job('SCRIPT_JOB3'); END; *ERROR at line 1:ORA-27369: job of type EXECUTABLE failed with exit code: 7 !@#--!@#7#@!--#@!&ORA-06512: at "SYS.DBMS_ISCHED", line 209ORA-06512: at "SYS.DBMS_SCHEDULER", line 594ORA-06512: at line 1


These are just some portions of my tests. There were other things I have tried such as incorrect passwords and etc and they were all failing with exit code of 7. At this point, I am not completely sure if this is a bug or part of the design.