Oracle Apex 4.02 RHEL 5 - Error Installing APEX 4.0 : APEX is Shown as INVALID in DBA_REGISTRY

I'm doing an Apex install on 11g 11.2.0.2 RHEL 5 Apex 4.02 and the databse did not have Oracle TEXT and XML DB setup properly before I attempted the full devleopment environment install. Yes, this is my fault and resulted in an error.

I detected the problem, ran the Apex remove script and re-installed, still not joy.

Oracle Support pointed out several excellent resource that I should hav read before I did this and a great script for pre checking the environment.

Here's the information:

Check these documents:

APEX Installation Verification Script (Doc ID 1254932.1)


Here's the steps I run to install (note this is using EPG) and the resulting errors.

These are the steps we followed:

sqlplus / as sysdba
@?/rdbms/admin/owminst.plb
alter system set shared_servers = 5 scope=spfile;
alter system set shared_pool_size=200m;

shutdown immediate
startup

CREATE BIGFILE TABLESPACE APEX DATAFILE '/fs0/oracle/oradata/niku/apex001.dbf' SIZE 1G AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED LOGGING ONLINE PERMANENT 
EXTENT MANAGEMENT LOCAL AUTOALLOCATE BLOCKSIZE 8K SEGMENT SPACE MANAGEMENT AUTO;

CREATE BIGFILE TABLESPACE xdb DATAFILE '/fs0/oracle/oradata/niku/xdb001.dbf' SIZE 1G AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED LOGGING ONLINE PERMANENT 
EXTENT MANAGEMENT LOCAL AUTOALLOCATE BLOCKSIZE 8K SEGMENT SPACE MANAGEMENT AUTO;

-- install xdb as documented here http://www.adp-gmbh.ch/ora/xml_db/install.html
@?/rdbms/admin/catqm.sql xdb xdb temp 

sqlplus / as sysdba @?/rdbms/admin/catblock.sql

-- install Oracle Text as documented here http://www.oraclekonsulent.dk/en/index.php?blog_id=185
@$ORACLE_HOME/ctx/admin/catctx.sql change_on_install SYSAUX TEMP NOLOCK;

connect ctxsys/ctxsys

 @?/ctx/admin/defaults/drdefus.sql

Follow the directions here http://download.oracle.com/docs/cd/E17556_01/doc/install.40/e15513/otn_i...
sqlplus / as sysdba @apexins APEX APEX TEMP /i/

sqlplus / as sysdba @apxldimg.sql /tmp

sqlplus / as sysdba @apxchpwd.sql

ALTER USER APEX_PUBLIC_USER IDENTIFIED BY apex;

EXEC DBMS_XDB.SETHTTPPORT(8080);

DECLARE
  ACL_PATH  VARCHAR2(4000);
  ACL_ID    RAW(16);
BEGIN
  -- Look for the ACL currently assigned to '*' and give APEX_040000
  -- the "connect" privilege if APEX_040000 does not have the privilege yet.

  SELECT ACL INTO ACL_PATH FROM DBA_NETWORK_ACLS
   WHERE HOST = '*' AND LOWER_PORT IS NULL AND UPPER_PORT IS NULL;

  -- Before checking the privilege, ensure that the ACL is valid
  -- (for example, does not contain stale references to dropped users).
  -- If it does, the following exception will be raised:
  --
  -- ORA-44416: Invalid ACL: Unresolved principal 'APEX_040000'
  -- ORA-06512: at "XDB.DBMS_XDBZ", line ...
  --
  SELECT SYS_OP_R2O(extractValue(P.RES, '/Resource/XMLRef')) INTO ACL_ID
    FROM XDB.XDB$ACL A, PATH_VIEW P
   WHERE extractValue(P.RES, '/Resource/XMLRef') = REF(A) AND
         EQUALS_PATH(P.RES, ACL_PATH) = 1;

  DBMS_XDBZ.ValidateACL(ACL_ID);
   IF DBMS_NETWORK_ACL_ADMIN.CHECK_PRIVILEGE(ACL_PATH, 'APEX_040000', 
     'connect') IS NULL THEN 
      DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(ACL_PATH, 
     'APEX_040000', TRUE, 'connect'); 
  END IF;

EXCEPTION
  -- When no ACL has been assigned to '*'.
  WHEN NO_DATA_FOUND THEN
  DBMS_NETWORK_ACL_ADMIN.CREATE_ACL('power_users.xml',
    'ACL that lets power users to connect to everywhere',
    'APEX_040000', TRUE, 'connect');
  DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL('power_users.xml','*');
END;
/
COMMIT;

-- enable anonymous access if you want

DECLARE
  ACL_PATH  VARCHAR2(4000);
  ACL_ID    RAW(16);
BEGIN
  -- Look for the ACL currently assigned to '*' and give APEX_040000
  -- the "connect" privilege if APEX_040000 does not have the privilege yet.

  SELECT ACL INTO ACL_PATH FROM DBA_NETWORK_ACLS
   WHERE HOST = '*' AND LOWER_PORT IS NULL AND UPPER_PORT IS NULL;

  -- Before checking the privilege, ensure that the ACL is valid
  -- (for example, does not contain stale references to dropped users).
  -- If it does, the following exception will be raised:
  --
  -- ORA-44416: Invalid ACL: Unresolved principal 'APEX_040000'
  -- ORA-06512: at "XDB.DBMS_XDBZ", line ...
  --
  SELECT SYS_OP_R2O(extractValue(P.RES, '/Resource/XMLRef')) INTO ACL_ID
    FROM XDB.XDB$ACL A, PATH_VIEW P
   WHERE extractValue(P.RES, '/Resource/XMLRef') = REF(A) AND
         EQUALS_PATH(P.RES, ACL_PATH) = 1;

  DBMS_XDBZ.ValidateACL(ACL_ID);
   IF DBMS_NETWORK_ACL_ADMIN.CHECK_PRIVILEGE(ACL_PATH, 'APEX_040000', 
     'connect') IS NULL THEN 
      DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(ACL_PATH, 
     'APEX_040000', TRUE, 'connect'); 
  END IF;

EXCEPTION
  -- When no ACL has been assigned to '*'.
  WHEN NO_DATA_FOUND THEN
  DBMS_NETWORK_ACL_ADMIN.CREATE_ACL('power_users.xml',
    'ACL that lets power users to connect to everywhere',
    'APEX_040000', TRUE, 'connect');
  DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL('power_users.xml','*');
END;
/
COMMIT;

sqlplus / as sysdba @?/rdbms/admin/utlrp.sql

Check the status of the APEX install with

SELECT STATUS FROM DBA_REGISTRY WHERE COMP_ID = 'APEX';

At this point you should have a working Apex install on port 8008 of your server. Test it with

http://hostname:8080/apex