13 dic. 2009

Install Oracle PDO PHP (php_oci) driver in Ubuntu Hardy (8.04)

Ubuntu Hardy comes with some PHP PDO driver like mysql, postgresql and sqlite. Trying to install Oracle driver with:
sudo pecl install php_oci

fails in my Ubuntu with the following error:
pear/PDO_OCI requires PHP extension "pdo" (version  >= 1.0)

Isn't "pdo" installed already? It is part of php5-common, but PEAR/PECL doesn't know about it. So let's go ahead with ignoring dependency checks:
sudo pecl install -n php_oci

If you haven't installed php5-dev you'll get the following error:
sh: phpize: not found
ERROR: `phpize` failed

So install php5-dev, if you didn't already do it. Now, running the former pecl could yield:
...configure: error:
You need to tell me where to find oracle SDK, or set ORACLE_HOME.

Isn't ORACLE_HOME already set? Running a
should answer this doubt. In my environment, it's set, but sudo doesn't pass it to the command, let's try again:
sudo -E pecl install -n pdo_oci

configure: error: Cannot find php_pdo_driver.h

The configure script tries to find it in:

This directory tree is empty or non-existent (in my Ubuntu).
cd /usr/include
sudo rm -rf php
sudo ln -s /usr/include/php5 php

Now the install succeeds. We have to enable it in /etc/php5/conf.d. Create a file 'pdo_oci.ini' with the following content:
#config por PDO OCI Oracle

Let's test is with php interactive mode:

$ php -a
php > $dbh = new PDO('oci:dbname=xe', 'system', '<password>');
php > $sql = 'select * from dual';
php > foreach ($dbh->query($sql) as $row){
php { print_r($row);
php { }
[DUMMY] => X
[0] => X
php > [Control-D]

If we create now a simple php page which tries to show some Oracle output we get a PHP error message (depending on how error reporting is configured in PHP, it may not be rendered in PHP page, but be present in the log):
PDOException: SQLSTATE[]: pdo_oci_handle_factory: OCI_INVALID_HANDLE (/tmp/pear/cache/PDO_OCI-1.0/oci_driver.c:463) in ... on line ...

The problem is that Apache has no access to the ORACLE_HOME environment variable. Just add it to /etc/apache2/envvars:
export ORACLE_HOME=<path to Oracle, mine is: /usr/lib/oracle/xe/app/oracle/product/10.2.0/server>

Now we should be done.

30 oct. 2009

OIOSAML and Blackboard / WebCT Vista/CE 8.0


When installing OIOSAML, incompatibility issues arise. This blog entry provides detailed information about how to fix this problem and may be applicable to other applications that need to run with Sun Java 1.5 and updated versions of JAXP 1.3.


Blackboard Vista / CE 8.0, formerly known as WebCT, uses Bea Weblogic 9.2 application server, including Sun Java 1.5. OIOSAML requires and provides an updated version of JAXP 1.3, which is part of Java 1.5 core library. To override internal libs in Java 1.5, you have to "endorse" the new libraries. This is correctly described in OIOSAML docs.


When starting the Weblogic server, the following error appears:
weblogic.management.ManagementException: [Management:141266]Parsing Failure in config.xml:
javax.xml.namespace.QName; local class incompatible:
stream classdesc serialVersionUID = 4418622981026545151, local class serialVersionUID = -9120448754896609940

How to fix the problem

You have to include the following option in JAVA_OPTIONS ($webct_domain_dir/customconfig/startup.properties):

The startup.properties already contains:

But the provided xerces library (2.9.1) has another property name as the one provided with Sun Java 1.5.

Detailed description

When Sun included JAXP 1.3 in Java 1.5, it changed the namespace in all source files. It also specified an explicit serialVersionUID for javax.xml.namespace.QName. In Java 1.5, the serialVersionUID was explicitly specified as 4418622981026545151 (0x3d521a30bc76fdff). But in previous versions of JAXP (xerces) this was implicitly calculated as : -9120448754896609940 ( 0x816da82dfc3bdd6c).

The already serialized data could not be deserialized. SUN corrected this error in next releases, introducing a compatibility flag

which having the value 1.0 switches to the Java 1.5 serial UID.

The Xerces project people picked up this change in newer version of xerces, but changed the flag name to

I recommend setting both of the settings. As the 'com.sun' options is already specified you just need to specify the 'org.apache' one:
JAVA_OPTIONS="$JAVA_OPTIONS -Dorg.apache.xml.namespace.QName.useCompatibleSerialVersionUID=1.0