Monday, December 5, 2016

APEX plugin files and 404 not found in ORDS

After installing APEX 5.0.4 and ORDS 3.0.8 I had an issue where APEX plugins that have static files bundled with the plugin (files that at runtime get mapped to URLs such as /ords/your_workspace_name/r/your_app_id/files/plugin/123456789/v1/filename) were giving a 404 "not found" error from ORDS. Well, you actually have to open the console in the web browser to see the 404 errors, and then if you try to open the file directly you get a 404 page from ORDS:

I had seen this problem before, and it is typically because you have not run the apex_rest_config.sql script as part of your APEX installation, as explained by Patrick Wolf here and also in the docs.

However, in my case I was fairly certain I had already run the apex_rest_config.sql script. I re-ran it just in case (and restarted Tomcat), but I still got the error.

I then inspected the Tomcat log files (look in /usr/share/tomcat8/latest/logs/catalina.out) and found the following:

SEVERE [ajp-nio-8009-exec-1] . *** The pool named: |apex|pu| is reporting no APEX workspaces are enabled for RESTful Services,
 but the pool named: |apex|al| is reporting 1 workspaces are enabled.
This implies APEX was installed after Oracle REST Data Services. Please run the following command and restart Oracle REST Data Services:
        java -jar ords.war validate --database apex
APEX based RESTful Services, including those used to serve static resources will not function until this has been done.

So I did as instructed and ran this command

java -jar ords.war validate --database apex

and then restarted Tomcat

service tomcat restart

And that resolved this issue.


Dietmar Aust said...

Hi Morten,

nowadays (learning from the multitude of issues between ords and apex) I always recommend to keep things separated.

Meaning I use two instances of ords (ords.war and rest.war as a copy of ords.war) and configure them completely separately with separate configuration directories.

When using java -jar ords.war install advanced I can choose NOT to install the ORDS_METADATA repository for an APEX environment (the ADVANCED part is critical here). Thus I can access apex via /ords and (if and only if required) the new rest support using /rest, makes my life a whole lot easier.

Plus, I can easily use a higher version of ORDS for APEX without having to patch the repository in the database backend (because it doesn't use ords_metadata at all).
Also I can serve multiple apex instances having different versions of ords_metadata installed in the backend ...

This approach is just sooo much better, don't have theses issues any more at all.


Morten Braten said...

@Dietmar: Thanks for the feedback, that's a great tip!

- Morten