Thursday 12 May 2022

Run two different Apex versions on a single standalone ORDS

A single standalone ORDS can handle multiple database connections with Apex as described here. But without additional configuration, this can be problematic if not all Apex instances are on the same version. For example, in the Developer VM Project, we have two PDB's with APEX locally installed at version 21.5.

When upgrading one PDB to Apex 22.1, the last step according to the documentation is Copying the Images Directory. After that step, the images directory files are on version 22.1 whereas the unpatched 2nd PDB is still running 21.5, which will lead to the following error:

Error: There is a problem with your environment because the Application Express files are not up-to-date!

So as long as not all Apex environments on a given ORDS instance are updated within the same maintenance window, seperate images directories are needed for at least any Apex version running on that ORDS. An image prefix maps to a virtual directory, for more information see Image Prefix changes in Oracle Application Express 4.2.2.

I have found no solution to configure multiple virtual directories on for standalone ORDS. But even with only a single static files directory, several file versions can be put below that single root.

Just organize the files in separate directories per version like images/images-21-5. This can be configured per application under Shared Components/User Interface Attributes.

If you have more than one application on the Apex instance, the setting could be set at once for the whole instance with the reset_image_prefix.sql script, that comes with your Apex installation under utilities. Usage is described in the MOS-Note How to Switch APEX to Use Oracle APEX Static Resources on Content Delivery Network (CDN) (Doc ID 2817084.1).
This script also does some cleanup which takes some time, so according to this blog post this is not recommended for production.

begin 
        apex_instance_admin.set_parameter(
            p_parameter => 'IMAGE_PREFIX',
            p_value     => '/i/images-21-5' );
        
        commit;
  end;

Alternatively this can be done with the above listed procedure, that does not do the invalidation. But in my instance, the changes took not effect immediately. So probably the invalidation in the script is there for a reason.

Especially if your Apex application is used over public internet, you might want to get rid of the static files anyways and use the the Content Delivery Network instead as described in Announcing Oracle APEX Static Resources on Content Delivery Network.