Weblog

Unexpected behaviour loading invalid XML document using XMLDB

XMLDB is a feature of the Oracle database for 9i release 2 and higher. It provides a high-performance, native XML storage and retrieval technology.
I have used Oracle XMLDB for querying XML documents using XQuery.
With XQuery you can query XML data just as SQL has been the query language for relational data.
To my opinion XMLDB is a very comprehensive and valuable feature of the database.
Cornerstone for XMLDB is the object type XMLType. You can create an object table or object column and bind a schema to this object using dbms_xmlschema.registerschema.
After binding the schema to this object you can import schema instances.
Most suprisingly i was able to load invalid xml documents, i.e. documents that do not conform to the schema, into the database without hitting any error.
The schema did define an element occurence restriction using minoccurs="1" (default). However i was able to load an instance without containing the element at all.
After consulting MetaLink i found out that this was expected behaviour. After loading a schema bound document you should validate the document using the schemavalidate() method of XMLType.
I found this very unexpected behaviour and i’m very eager to know the reason for this non-Oracle behaviour. Perhaps performance?

Google Web Toolkit (GWT)

Google just released their AJAX toolkit Google Web Toolkit. Their approach to writing AJAX web applications is pretty interesting. You write the entire application in Java, composing the user interface with widgets (A list of available widgets: google widget gallery), just like you would when writing a Swing application.

During development, and debugging your entire applications runs in java in a JVM (hosted mode). But when you deploy the application the GWT java-to-javascript compiler will transform the java application into javascript and html. This means that you can use a normal java IDE to develop your application, benefitting from code completion, compile time error checking, refactoring, etc. This also means that you don’t have to know all the differences between browsers, GWT will handle these automatically for you.

Other AJAX implementation issues like tranferring XML, marshalling and unmarshalling data into XML are also hidden from the developer. You just create serializable object, GWT handles the rest.

GWT could make a big impact on how AJAX application are built. It seems like a productive and easy way to create AJAX applications.

Do single page webapps improve usability?

Oracle created an AJAX dedicated page on their website some weeks ago: OTN: Ajax Resources, and Sun has now also created an AJAX page: AJAX Developer Resource Center. It’s good to see all these resources for developers, and having AJAX enabled JSF components is even better. But the question is, how far should we take this AJAX thing? I see no problem with simple form elements with improved validation or autocompletion, as long as we take accessibility into account. And i’m convinced that these components do improve usability. But it’s possible to create complete web applications in one webpage. Does this benefit the user, does it improve usability?

Get more understanding for your creative thought process

A couple of months ago I bought Code Complete, written by Steve McConnell, to serve as my programming bible during my daily work. While reading Code Complete, I immediately noticed that the book is full of interesting reference material, mostly on sofware related subjects. But fortunately not all…;)

One of the references in Code Complete that caught my specific attention is given in chapter 5: Design in Construction. In this chapter Steve McConnel refers to the book Conceptual Blockbusting: a guide to better ideas. This book is written by James L. Adams and was written to teach design to engineering students at Stanford. The book is all about creative thought processes and their possible blocks. The book discusess several conceptual blocks (like perceptual, emotional and cultural) that prevent us from realizing the full potential of our minds.

Half away the book, I’m now fascinated by the unconventional examples/exercises in the book that give me more feeling and understanding for the human creative thought process and about how our brains works and reacts to things we experience during our lives. Every time when I have finished an exercise I’m left with a feeling of “Yes, this is really amazing and true for me”..

I recommend this book to everyone who want to get more understanding for creative thought processes or just want to read a nice book in a different field ;)

InfoWorld: Oracle to boost AJAX, Java

Infoworld is running an article called: Oracle to boost AJAX, Java. According to this article Oracle will donate it’s AJAX technology to the Open Source. Oracle has already donated it’s JSF components to Apache: ADF Faces. The new donation will add AJAX support to JSF components:

“It allows people to work with the JSF components but [they] can display that using AJAX technology, which basically allows them to [have] a much richer environment in the browser”

Oracle will assist with the Grails project, which is a project to create a Ruby on Rails like development framework based on Java and Groovy.

Out of memory (java.lang.OutOfMemory) running Oracle BPEL Process Manager

Running Oracle BPEL requires a lot of reflective data, i.e. class and method objects, to be held by the Java virtual machine. This type of data is stored in a memory structure called the “permanent generation”. The default size for the permanent generation (64M) is for most applications sufficiently large.

But if you deploy the Oracle BPEL Manager together with one or more JSP applications into a single Oracle container you will most probably hit an out of memory exception. Raising the maximum heap size using the option -Xmx does not prevent the exception from occuring, since this option will only effect the young generation and the tenured generation. The permanent generation will never be visited by a minor or full garbage collection!

You should increase the permanent generation by using the option -XX:MaxPermSize=<size>. You can determine a correct maximum by running the container using the option -XX:+PrintHeapAtGC. This setting tells you something like the following:

PSPermGen total 61952K, used 61951K [0x851c0000, 0x88e40000, 0x891c0000)
However, I’m sure that using a value of 256M will always be large enough.

For more info you should visit Tuning Garbage Collection

Database migrations and collections

Database 8i and below initialized collections ( TYPE … is table of, TYPE record is … ) by default. This behavior changed in 9i and became even stricter in 10G.

For example you have the following code in 8i

CREATE OR REPLACE PROCEDURE proc_start ( p_procedure_name IN VARCHAR2)
IS
--
TYPE num_ntab_t IS TABLE OF NUMBER;
TYPE vc60_ntab_t IS TABLE OF VARCHAR2(60);
TYPE vc255_ntab_t IS TABLE OF VARCHAR2(255);
--
TYPE g_call_stack_t IS RECORD
( module vc60_ntab_t
, module_desc vc255_ntab_t
, stmt_no num_ntab_t
, stmt_desc vc255_ntab_t
);
--
g_call_stack g_call_stack_t;
--
li PLS_INTEGER;
--
BEGIN
--
g_call_stack.module.EXTEND;
g_call_stack.module_desc.EXTEND;
g_call_stack.stmt_no.EXTEND;
g_call_stack.stmt_desc.EXTEND;
li := g_call_stack.module.LAST;
--
g_call_stack.module(li) := SUBSTR(p_procedure_name,1,60);
g_call_stack.module_desc(li) := NULL;
g_call_stack.stmt_no(li) := 1.0;
g_call_stack.stmt_desc(li) := 'start';
--
END proc_start;

The code works perfectly in 8i, the construction of a record of tables instead of a table of records is a bit awkward though. Running the above code in 10G gives the following error.

ERROR at line 1:
ORA-06531: Reference to uninitialized collection
ORA-06512: at “SYSTEM.PROC_START”, line 17
ORA-06512: at line 1

Oracle provides us with a method to implement the old 8i behavior using a event ( alter system set event = ‘10943 trace name context level 2097152′ scope=spfile; , see metalink note 333955.1). In my opinion these kinds of solutions should be avoided at all costs. Better and more practical is to initialize the collection ourselves.

TYPE g_call_stack_t IS RECORD
(module vc60_ntab_t := vc60_ntab_t(),
module_desc vc255_ntab_t := vc255_ntab_t(),
stmt_no num_ntab_t := num_ntab_t(),
stmt_desc vc255_ntab_t := vc255_ntab_t()) ;

Using this code section in the declaration initializes a empty collection, you can also initialize a collection with default values. A table of records can be initialized in the following way.

Create or replace procedure create_employee
is
TYPE number_tab is table of number;
--
emps_tab number_tab := number_tab();
--
BEGIN
--
emps_tab.extend;
--
END;

Calling Operating System commands from the database

So now and then i have to implement the requirement to call an operating system command from the database. For the Oracle database implementing a call out is a fairly simple and straight forward task. Suprisingly, I have seen implementations using the java runtime in the database (JServer) using System.Runtime: a slow and big footprint solution for only calling an OS command.
The way to go is to use the feature external procedure call. The steps for calling an external C routine are:

  1. Create a library that contains the C-routine. (You can download the dll here for the Windows platform)

  2. Create a library object in the database to identify the library containing the C-routine.

    create or replace library lib_host as '<path to dll>\host.dll' (Windows)

    The preferred location for the library is the Oracle database ‘bin’ or ‘lib’ folder. If you prefer a non-default location you should add the bold line to your default SID description of your PLSExtProc in the listener.ora:

      (SID_LIST =
      (SID_DESC =
        (SID_NAME = PLSExtProc)
        (ENV = "EXTPROC_DLLS=ANY")
        (ORACLE_HOME = E:\oracle\product\server.1020)
        (PROGRAM = extproc)
        )
      )

  3. Finally, create a PL/SQL wrapper function/procedure to publish the C-routine:

      create function host( p_cmd IN varchar2 )
      return BINARY_INTEGER
      as external
      library lib_host
      name "host" language c;

Now, you can call an OS-command from within PL/SQL or even using SQL:

select host( 'echo test >c:\echo.out' ) from dual;

Oracle Portal Internet topology

The default Portal topology (see picture) requires a direct connection between the browser and the login server, aka Single Sign-On Server. For Internet deployment of Portal sites this topology is not well suited.
Due to security constraints you want to hide the login server from the Internet user. A common approach is to define two sites, one for the Oracle Portal midtier and a site for the login server.
default
If you want to configure SSL for the default port (443) you need two ip addresses, since each site requires a dedicated X509 certificate if you do not want a security warning popup in the browser.
To make internet deployment of Oracle Portal sites easier and more secure you can hide the login server from the internet by adding simple routing rules to the reverse proxy server, i.e. OracleAS WebCache (see picture).
All you have to do is to define three extra sites with the following distinct prefixes: /oiddas, /pls/orasso, /sso and /osso. The last step is to map all of these sites to the login server.
Make sure that you run the SSO configuration script, ssocfg, to change the default login server urls to the url of the reverse proxy.
internet

This topology fullfills the following functions:

  • It hides the host name of the login server;
  • It terminates an SSL connection at the proxy instead of at the login server;
  • It limits the number of ports exposed on a firewall;
  • It is more secure.

EJB3.0 specification unanimously approved by the JCP

Today, I read that on the 1th of May the JCP unanimously approved the EJB specification. So, EJB3 is now in it’s Final Approval Ballot stage and will soon be able in it’s final specification.

EJB 3.0 is coming!

Technology
Ben jij slim genoeg voor IT-eye