Friday, May 16, 2008

Adding IM (Jabber/XMPP) messaging to Oracle APEX

One of my APEX application relies heavily on email notifications for work flow approval and task assignment notification. A few months ago it occurred to me that it would be really nice to implement IM notification and let users decide how they like to be notified. So I went to work and found a great java open source XMPP/Jabber client called Smack. My first implementation was just a simple class that called smack functions loaded on the DB by loadjava. But I recently found a project started by Adrien Sales that wraps more of the Smack functions such as rosters. To add IM functionality to your application follow these steps:

  1. Download Oracle XMPP/Jabber Instant Messenger for Oracle 11G.
    If you are using Oracle 10g download from here (I had to recompile using an older smack version and JDK1_4)
  2. Login to sqlplus as sysdba and create account XMPP to load java classes and package.
    create user XMPP identified by XMPP
    default tablespace your_tablespace
    temporary tablespace your_temp_tablespace
    quota unlimited on users;
  3. From the shell go to the dist folder and excute
    loadjava -u XMPP/XMPP -resolve lib/smack.jar
    loadjava -u XMPP/XMPP -resolve lib/smackx.jar
    loadjava -u XMPP/XMPP -resolve OracleXMPP.jar
  4. Login to sqlplus as sysdba and execute:
    call dbms_java.grant_permission('PUBLIC', '', '*', 'accept, connect,
    listen, resolve');
    call dbms_java.grant_permission('PUBLIC', '', '*', 'accept, connect,
    listen, resolve');
  5. Connect as XMPP/XMPP and run the following script.

  6. Grant privileges on the new package to APEX_PUBLIC_USER:
    grant execute, debug on dbms_xmpp to APEX_PUBLIC_USER;
  7. Login to APEX to SQL Workshop> SQL Commands and test:
    select XMPP.dbms_xmpp.send_plain_text_message('',
    'XMPP Test',
    'Hello from Oracle APEX') xmpp_return_code
    from dual;
And thats it! Now if your company happens to be running a XMPP/Jabber server (like we do at Oracle) or if you have a user base that has gmail accounts or any of the other services running on XMPP, this could be a great alternative to emails. This is a huge hit on my applications and I bet anyone can come with more creative ways to include Jabber with APEX. Let me know how you use it.

I am also planning to post soon how I'm running my own Jabber server and how I can integrate it with my APEX application. Stay tuned!

For more information on Jabber please visit

Thursday, May 15, 2008

Apache 2 Compression with mod_deflate

Today, after a report from one my users that the our APEX application was getting "slower", I decided to implement mod_deflate for content compression. The performance is noticeable faster! I went with mod_deflate since is included in the Apache 2.0.x source package. Here is what I added to my httpd.conf:

LoadFile /usr/lib/
LoadModule deflate_module modules/

<IfModule mod_deflate.c>
# Insert filter
SetOutputFilter DEFLATE
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png|htc|wsdl|exe|t?gz|bz2|sit|rar|pdf|zip)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary

After that I all did was a quick
opmnctl restartproc ias-component=HTTP_Server
and voila!

For more information on mod_deflate go to

Tuesday, May 13, 2008

Adding Firefox Search Engine to APEX

Today, I got tired of constantly having to login to Metalink to search for SR's that I needed to check. I do have other tools (internal) that let me do the this (oracle forms) but I do prefer to use Metalink since it is built with APEX. So here is what I did to speed up the search process; I added this to my intranet APEX application so my users can install the search engine. I also created an alternate example using Ask Tom's Site.

First I created asktom.xml with the following (note that for space purposes could not include the whole data:image string. To create your own go to The data: URI kitchen).

<SearchPlugin xmlns="" xmlns:os="">
<os:ShortName>Ask Tom</os:ShortName>
<os:Description>Ask Tom Search</os:Description>
<os:Image width="16" height="16">data:image/x-icon,%01%01%10%10%01%20h% ...
<os:Url type="text/html" method="GET" template="{searchTerms}">

Then I added the following inside the <header> of this blog:

<link href='' rel='search' title='Ask Tom' type='application/opensearchdescription+xml'/>

Now all you have to do (assuming you are using Firefox) is go to the Search engine and go to the bottom where it says: Add "Ask Tom", and thats it!

You can create as many Search Engines and have them available to your Firefox users.
For more info visit