Wednesday, December 19, 2012

APEX: Running multiple version on single Weblogic Server

Sometimes you would like to have multiple versions of APEX running on one Weblogic Server, or Weblogic Cluster. For example, you would like to run APEX version 4.0 and version 4.2 along each other.

To configure this is rather simple and straight forward. The trick is to use the various WAR files; apex.war and images.war under a different name and use plan files to manipulate the root and image directories.

The following actions should be carried out:

make sure you have different WAR files of the APEX application in a single directory on your Admin server:

$ cd /data/deploy
$ ls -1
apex.4.0.war
apex.4.2.war
images.4.0.war
images.4.2.war


Create a plan directory to store your plan-files to overule the WEB properties

$ mkdir -p /data/user_projects/domains/APEX/plan/apex
$ ls -1
plan-images.4.0.xml
plan-images.4.2.xml
plan.4.0.xml
plan.4.2.xml


Make sure you have these files in this directory. Here is an example of the APEX plan-images file, to create your own plan file:

plan-images.4.2.xml
<?xml version='1.0' encoding='UTF-8'?> 
<deployment-plan xmlns="http://xmlns.oracle.com/weblogic/deployment-plan" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/weblogic/deployment-plan http://xmlns.oracle.com/weblogic/deployment-plan/1.0/deployment-plan.xsd" global-variables="false">
 
<application-name>apex.war


  <variable-definition>
     
<variable>
         
<name>apex-images-root</name>
         
<value>apex-images-42</value>
     
</variable>
 
</variable-definition>

 
<module-override>

   
<module-name>images.4.2.war</module-name>
   
<module-type>war</module-type>

   
<module-descriptor external="false">
     
<root-element>weblogic-web-app</root-element>
     
<uri>WEB-INF/weblogic.xml</uri>

     
<variable-assignment>
       
<name>apex-images-root</name>
       
<xpath>/weblogic-web-app/context-root</xpath>
     
</variable-assignment>

   
</module-descriptor>
 
</module-override>

 
<config-root>/data/tmp/apex</config-root> </deployment-plan>

Here is an example of the APEX plan file:

plan.4.2.xml 
<?xml version='1.0' encoding='UTF-8'?> 
<deployment-plan xmlns="http://xmlns.oracle.com/weblogic/deployment-plan" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/weblogic/deployment-plan http://xmlns.oracle.com/weblogic/deployment-plan/1.0/deployment-plan.xsd" global-variables="false">
 
<application-name>apex.4.2.war</application-name>

 
<variable-definition>
     
<variable>
         
<name>apex-root</name>
         
<value>apex-42</value>
     
</variable>
     
<variable>
         
<name>apex-config</name>
         
<value>/data/configuration/4.2</value>
     
</variable>
 
</variable-definition>

 
<module-override>
   
<module-name>apex.4.2.war</module-name>
   
<module-type>war</module-type>

   
<module-descriptor external="false">
     
<root-element>weblogic-web-app</root-element>
     
<uri>WEB-INF/weblogic.xml</uri>

     
<variable-assignment>
       
<name>apex-root</name>
       
<xpath>/weblogic-web-app/context-root</xpath>
     
</variable-assignment>

   
</module-descriptor>

   
<module-descriptor external="false">
     
<root-element>web-app</root-element>
     
<uri>WEB-INF/web.xml</uri>

     
<variable-assignment>
        
<name>apex-config</name>
        
<xpath>/web-app/context-param/[param-name="config.dir"]/param-value</xpath>
        
<operation>add

      </variable-assignment>

   
</module-descriptor>
 
</module-override>

 
<config-root>/data/tmp/apex</config-root></deployment-plan>

Now comes the deployment part, which is straight forward as a normal application.
  • Logon to Adminconsole
  • Lock & Edit to open session
  • Deploy images.4.0.war with plan file plan-images.4.0.xml
  • Deploy images.4.2.war with plan file plan-images.4.2.xml
  • Deploy apex.4.0.war with plan file plan.4.0.xml
  • Deploy apex.4.2.war with plan file plan.4.2.xml
  • Activate changes
  • Start running the images applications for all requests
  • Start running the apex applications for all requests
While we have overuled the default images direcotry from '/i' into '/apex-images-42' or '/apex-images-40', we should run some SQL scripts to update the APEX data. The following SQL code should be execute on the database for the specific APEX version

declare
    l_stmt varchar2(4000);
begin
    l_stmt := 'create or replace package wwv_flow_image_prefix
is
    g_image_prefix       constant varchar2(255) := ''/
apex-images-42/'';
end wwv_flow_image_prefix;';

    execute immediate l_stmt;
end;
/

update wwv_flows
       set flow_image_prefix = '/apex-images-42/'
     where flow_image_prefix = '/i/';

commit;

begin
    wwv_flow_page_cache_api.purge_all;
end;
/

commit;

begin
    dbms_utility.compile_schema(schema => 'APEX_040200', compile_all => FALSE);
end;
/


Now you are able to run multiple APEX applications from onw Weblogic Server/Cluster:

http://:/apex-42
http://:/apex-40