Well let me first start with this, I can reproduce this bug and I also have a work around, I hope this workaround works till Apex team fixes this bug :) I also opened up a Support Request for this issue. It's funny I found a similar issue with Oracle Apex 4.1 upgrade in 2012. I hope the the Team didn't uncomment that code fix :)
https://balajichellappa.blogspot.com/2012/05/apex-41-resultcachemode-force-apex-bug.html
Issue Description:
Ok, let's get into the issue. Let's say you have a Master App with ID 1000 and created a WC with App ID 1001.
You made changes to 1001, merged all your changes to WC, deleted it and then recreated WC with 1001.
Then when you try to login to the WC 1001, login page will render fine, but get an error when you hit the submit button “login” saying "Item ID (P9999_USERNAME) is not an item defined on the current page."
Same will work fine, if you create a completely new WC let's say 1002 and login.
The odd thing, if you leave the DB running for a day and next day when you come back and login to the App 1001 it will just work fine.
My speculation about this issue:
I believe this is caused by the RESULT CACHE optimization setting and the old page with old Apex internal Item ID for "P9999_USERNAME" is Cached in memory which is not found in the new WC.
Workaround:
Just Flush the Result Cache and things will start to work.
BEGIN
DBMS_RESULT_CACHE.FLUSH;
END;
Ideally we should flush the Shared Pool “ALTER
SYSTEM
FLUSH
SHARED_POOL
” But you don't have access in ADB.
PS: I over simplified the issue for explanation purpose. Actually this issue is driving us crazy, because we will make changes to the app, application process etc, it will save fine, but when we render the page in the app it will execute the old code driving the developer crazy.
One more things. This is not always reproducible, especially after Flushing the cache. You have to wait for some time to for the memory to fill up.
Apex Team,
Hope this helps and you can get to the bottom of this issue.