ORA-46238: Database user or role does not exist during Upgrade to 12c using dbua

I recently ran into “ORA-46238: Database user or role does not exist ” issue while trying to upgrade Oracle database from 11g to 12c using DBCA.

You will see something like this in your logfile 

ERROR at line 1: 
ORA-46238: Database user or role '"BETADATASECURE"' does not exist 
ORA-06512: at "SYS.XS_ACL", line 93 
ORA-06512: at "SYS.XS_ADMIN_UTIL", line 53 
ORA-06512: at "SYS.XS_ACL_INT", line 126 
ORA-01403: no data found 
ORA-06512: at "SYS.XS_ACL_INT", line 122 
ORA-06512: at "SYS.XS_ACL_INT", line 493 
ORA-06512: at "SYS.XS_ACL", line 83 
ORA-06512: at "SYS.XS_OBJECT_MIGRATION", line 190 
ORA-06512: at "SYS.XS_OBJECT_MIGRATION", line 190 
ORA-06512: at line 56 
ORA-06512: at line 104

Reason : – You have dropped the user but there are still some permission lingering out there for that user. You can using the following.

SQL> SELECT a.object_id ACL_ID, b.principal, b.privilege
2 FROM xdb.xdb$acl a,
3 xmltable(xmlnamespaces(DEFAULT 'http://xmlns.oracle.com/xdb/acl.xsd'),
4 '/acl/ace' passing a.object_value
5 columns
6 principal VARCHAR2(30) path '/ace/principal',
privilege xmltype path '/ace/privilege') b
7 8 WHERE b.principal = 'BETADATASECURE';

ACL_ID PRINCIPAL
-------------------------------- ------------------------------
PRIVILEGE
--------------------------------------------------------------------------------
6013F2CBD4F65F5CE040007F01001457 BETADATASECURE
<privilege xmlns="http://xmlns.oracle.com/xdb/acl.xsd">
<plsql:connect xmlns:p

Drop permission : – 

connect / as sysdba
BEGIN
DBMS_NETWORK_ACL_ADMIN.delete_privilege (
acl => '/sys/acls/qualdatasecure.xml',
principal => 'BETADATASECURE',
is_grant => TRUE,
privilege => 'connect');
COMMIT;
END;
/