Sunday, August 2, 2020

HTTP 404 when enabling Friendly URLs or referencing Static Application Files using substitution string #APP_IMAGES#

Updated on Saturday, Nov 6, 2021 with following,

APEX/ORDS database accounts could also cause this issue, diagnose & solution regarding these accounts are added.
As it is known, Oracle is trying to deprecate two web listeners Oracle HTTP Server (mod_plsql) and Embedded PL/SQL Gateway, and Oracle REST Data Services (ORDS) will be the only supported web listener for APEX.

However, if ORDS is not configured properly, error HTTP/HTTPS 404 could happen when

1. Friendly URLs property is enabled in APEX application

Error message as following
404 Not Found

When Friendly URLs property is enabled, the URL format looks like
https://apex.lab.dbaplus.ca:7501/ords/myworkspace/r/myapp

Here, myworkspace is the value of RESTful Path Prefix property of APEX Workspace, default to the workspace name; myapp is the value of Application Alias property of APEX Application, default to the application name.

If Friendly URLs property is disabled, the URL format looks like
https://apex.lab.dbaplus.ca:7501/ords/f?p=101

Here, 101 is the application ID of APEX application.

2. Substitution string #APP_IMAGES# is used to reference an image in Static Application Files

Error message as following
404 Not Found
The request could not be mapped to any database. Check the request URL is correct, and that URL to database mappings have been correctly configured

The referencing syntax looks like
<img src="#APP_IMAGES#logo.gif">

It will be translated into following format before sent to browser,
<img src="test/r/101/files/static/v4/logo.gif">

Cause
It is one of following issues:

1.  APEX/ORDS database account(s) is/are locked or password-expired
2.  ORDS is not configured properly. E.g., incorrect option is chosen while installing ORDS 

Solution

1.  Validate following APEX/ORDS database accounts' status,

     APEX_LISTENER
     APEX_PUBLIC_USER
     APEX_REST_PUBLIC_USER
     ORDS_PUBLIC_USER

Validation SQL as following (run as system or sys)
select username,account_status
  from dba_users
 where username in ('APEX_LISTENER','APEX_PUBLIC_USER','ORDS_PUBLIC_USER','APEX_REST_PUBLIC_USER');
Sample output, 
USERNAME                  ACCOUNT_STATUS
------------------------- --------------
APEX_LISTENER             OPEN
APEX_PUBLIC_USER          OPEN
APEX_REST_PUBLIC_USER     OPEN
ORDS_PUBLIC_USER          OPEN
If any account's status is not open, you have to fix it by unlocking or resetting password. If the password is changed, you also have to change the password in ORDS configuration file.

2. If all accounts' status are OPEN, the errors are caused by incorrect ORDS configuration. They can be fixed by executing following command
java -jar ords.war validate --database apex

If the error is still there, try following command
java -jar ords.war install advanced

2 comments:

Fernando said...

Here I describe what, in my case, was the real problem for this issue. Hopefully it can help somebody:

https://community.oracle.com/tech/developers/discussion/4485245/can-create-applications-but-cant-run-them-whats-missing

Regards,
Fernando

DBA Plus said...

Thank you Fernando for your sharing!

I updated my post based with validating apex/ords accounts based on your suggestion.