Monday, 10 October 2011

Upgrading to APEX 4.1

Today I finally upgraded the APEX instance on my laptop to 4.1, and I'm very keen to start playing with the new goodies once I start finish my AUSOUG conference presentation.

When installing/upgrading anything Oracle, it's always a good start reading through the relevant installation notes. In my case, I started here:
Installing/upgrading with Apex Listener
http://download.oracle.com/docs/cd/E23903_01/doc/doc.41/e21673/otn_install.htm#BABEHJHG

I've heard some people are a little daunted sometimes with these notes - it's a shame because they are useful & concise. I've summarised the steps I needed to take below - as out of that page I linked to above - I only needed to apply a small percentage of commands. (I have APEX running on Glassfish on a Windows box)

1) First, I downloaded the software I needed for my system. Googling "download oracle apex" is always the best place to start for getting what you need.

I unpacked it to a fresh folder on my C drive:

2) Then I opened up SQL*Plus, ensuring my "Start in" was set to "c:\apex41", then logged in as SYS.
I ran the following script, which took about 15 minutes to run through and rejig my APEX 4.0 to 4.1
@apexins apex sysaux temp /i/

3) Then I had to copy all the images to my application server folder. APEX 4.1 has some fresh icons & updates to various supporting software like JQuery - so that needed to be updated.
However before I did this I backed up my existing images folder as I had modified some themes.
This is the command I executed:
xcopy /E /I C:\apex41\images C:\glassfishv3\glassfish\domains\domain1\docroot\i

The first time I ran I had permission issues overwriting the files, so I turned off read only for files in the folder. I probably should have thought a little harder over this, but since this laptop is very much localised just for my use, it didn't concern me much.

4) Before I did any cleaning up, I wanted to ensure I could log into the updated 4.1 instance, so I opened up the APEX log in page only to see the following error:
ORA-01658: unable to create INITIAL extent for segment in tablespace APEX

Turns out my tablespace was full, so I added another datafile:
alter tablespace apex
add datafile 'C:\app\Scott\oracle\11.2.0\oradata\sw11g\apex_b.dbf'
SIZE 500M;


From then I was able to log in successfully.

5) Then I decided to clean out any old users I had, so I ran this slightly modified SQL to list the users I could drop:
SELECT 'drop user '||username||' cascade;' ddl
   FROM dba_users 
 WHERE (username LIKE 'FLOWS_%' OR USERNAME LIKE 'APEX_%') 
   AND USERNAME NOT IN (
        SELECT 'FLOWS_FILES' 
          FROM DUAL 
         UNION 
        SELECT 'APEX_PUBLIC_USER' FROM DUAL 
         UNION
        SELECT SCHEMA s 
           FROM dba_registry
         WHERE comp_id = 'APEX');

DDL
----------------------------------
drop user APEX_040000 cascade;
drop user APEXLIB cascade;
drop user APEX_030200 cascade;
And after executing those drop statements my tablespaces got a little lighter anyway.

6) The only issue I've spotted so far is my modified login page, (thanks to Peter Raganitsch)
When opening my log in page, I noticed the following error in my console window - and my modifications weren't showing;
Error: uncaught exception: Syntax error, unrecognized expression: [src$=apex-logo-white.gif]

A quick google revealed this sort of response:
http://forum.jquery.com/topic/error-after-upgrade-to-jquery-1-5-in-img-src-new-png

So in our case this is probably due to the APEX team upgrading from JQuery 1.4.2 to 1.6.2 - so keep an eye out for that when you test your existing applications, if they use JQuery.

So I had a play with the code in the ApexLib_Loginpage.js script. I had to change this:
var vLoginTitle$ = jQuery("img[src$=apex-logo-white.gif]").parent();
to this, noting the quote usage:
var vLoginTitle$ = jQuery('img[src$="apex-logo-white.gif"]').parent();

This meant lines containing the bold also needed modification (to what you see here)
var vLoginRegionLogoImage$ = jQuery('img[src$="apex-db-apps.png"]');
jQuery('a[href^="f?p=4550:7:"]').parents(".rounded-corner-region").css("display","none");
jQuery('a[href^="f?p=4600:6:"]').parents(".rounded-corner-region").css("display","none");
jQuery('a[href="http://forums.oracle.com/forums/forum.jspa?forumID=137"]').parents(".rounded-corner-region").css("display","none");

So the upgrade took about 15 minutes computing time & about half an hour of my time, plus me sledgehammering jQuery to make it work.

Happy coding! Now, about that presentation...

Scott
Post a Comment