After months of delay I’ve finally switched all my database creation scripts to Incanto. The most obvious benefit is that my Ant build scripts are now more portable, as I am no longer exec’ing a shell script wrapper to sqlplus, and I no longer need Cygwin to run the build scripts on my Windows workstation. One of the nice features about Incanto is that it allows you to pass in an Ant propertyset which is used to define SQL*Plus variables for the invoked scripts. I find this useful for overriding schema names and allowing multiple sets of application schemas to be created in the same developer database, for example when researching support issues alongside new development. The Incanto website has a page of best practices including a <macrodef> which I placed in a shared build file and <import>ed into my various Ant scripts.

Incanto requires sqlplus to be on the PATH, so I handle that and setting login parameters in .antrc. One strange issue I encountered on SLES while making this transition was that even although sqlplus was on my PATH and executable from my shell scripts, when I used Incanto I got sqlplus: not found

Changing the permissions on sqlplus from 750 to 755 resolved the issue, even though the executable already belonged to a secondary group of which I was a member. Note that if you don’t need the advanced features of sqlplus you can still execute PL/SQL with Ant’s sql task.

Subversion on Ubuntu – Multiple Repositories

Eighteen months have passed since I setup Subversion on Ubuntu and I’ve found multiple repositories are valuable for providing finer grained access control and easier storage management. Here is a revised incantation:

su -
adduser --system --home /srv/svnrepos --gecos "System account to run svnserve" svn
apt-get install subversion xinetd
cat >> /etc/xinetd.d/svn << "EOF"
service svn
        port                    = 3690
        socket_type             = stream
        protocol                = tcp
        wait                    = no
        user                    = svn
        server                  = /usr/bin/svnserve
        server_args             = -i -r /srv/svnrepos
/etc/init.d/xinetd restart

# for each repository, eg. myrepo1
svnadmin create /srv/svnrepos/$repo
chown -R svn:nogroup /srv/svnrepos

# uncomment line to use default password file
vi ~svn/$repo/conf/svnserve.conf

cat >> ~svn/$repo/conf/passwd << "EOF"
fred = *****

Google Trends – Databases & Languages

Google Trends is a great tool for graphing search term popularity over time. Here is a comparison of searches for several makes of database.


Perhaps it’s a quirk of the phrases I used, but I was surprised to see Oracle so dominant, and even MySQL more popular than SQL Server.  PostgreSQL languishes in obscurity compared to MySQL, and Ingres barely registers at all.

Here’s some languages that I’m interested in.  Java is hugely dominant.


Let’s take out Java and zoom in.  I was surprised to see Ruby’s recent decline relative to Python.  Books on Scala have come out only recently.


Looking more specifically at JVM language dialects I’m surprised to see Jython competing so strongly with JRuby.  I’m not sure if I picked the right phrase for Groovy.


Choosing tools solely on the basis of popularity is obviously not a great idea, but I do feel better now about continuing to use Oracle, Java and Python.

P.S. See also the TIOBE Programming Community Index

cx_Oracle callfunc()

I like wrapping database queries in stored procedures: it keeps the SQL in the database, where Oracle can track its dependencies and flag if some change makes it invalid.  Here’s an example using Oracle’s demo schema SCOTT:

   TYPE emp_t
      RECORD( ename  varchar2( 10 ), hiredate date, sal     number( 7, 2 ) );
   TYPE emp_csr_t IS REF CURSOR
      RETURN emp_t;
   FUNCTION get_emps
      RETURN emp_csr_t;
   FUNCTION get_emps
      RETURN emp_csr_t
      c   emp_csr_t;
      OPEN c FOR SELECT   ename, hiredate, sal FROM scott.emp;
      RETURN c;

Now suppose I want to take the output from a stored procedure like the one above and write it to a CSV file.  In Python this is trivially easy:

 import cx_Oracle
 import csv
 reportName = 'emp_extract_k.get_emps'
 connection = cx_Oracle.connect(userid)
 cursor = connection.cursor()
 rs = cursor.callfunc(reportName, cx_Oracle.CURSOR)
 fd = open(reportName+'.csv', 'w')
 csvFile = csv.writer(fd)
 header = []
 [header.append(col_defn[0]) for col_defn in rs.description]
 for r in rs:

VBScript will never die, just fade away

I was looking for an official announcement of the end of life of VBScript but could not find one.  Instead I stumbled across the following MSDN blog post with a vague reference: "I believe that it was [at the] IT Forum in Nov 2005 that this was announced."  A colorful blog post from Ryan Stemkoski made me laugh, the comments are interesting also.  The closest I could find to an official Microsoft announcement was a blog post five years ago by Eric Lippert, who admitted to being the last person to ever add a feature to VBScript, in November 2000.

Adding a surrogate key to an Oracle table

This works for me for a mid-sized table.

ALTER TABLE foo ADD ( foo_id integer )
   l_foo_id   foo.foo_id%TYPE;
   IF :new.foo_id IS NULL
      SELECT   foo_id_seq.nextval INTO l_foo_id FROM dual;

      :new.foo_id := l_foo_id;
   END IF;
UPDATE   foo
   SET   foo_id = NULL
   ON foo( foo_id )

SDWest 2009

Monday. Disappointed to discover the coding dojo cancelled. Guessing that not enough people knew what it was and were not prepared to sign-up beforehand. Sat in instead on Scott Meyers’ ‘Better Software – No Matter What’: familiar material by a good presenter. Sofware quality depends on programmers, and how they exercise their discretion in implementing requirements: providing guidelines makes a significant difference. Insist on useful requirements. Create interfaces that are easy to use correctly and difficult to use incorrectly. Use design by contract to specify requirements using pre-conditions, post-conditions and invariants. Embrace static analysis. Favor constructor parameters over singletons.

Lunchtime presentation by Robert Martin, giving some inside history on Agile and Scrum, and how that has led to today’s movement for software craftsmanship.

Afternoon session on easyb and Groovy with Rod Coffin and Andy Glover: slow start before plunging into use of the requirements domain specific language with IntelliJ and Eclipse. Tested and documented version of a LIFO stack implemented with remarkable speed.

Evening discussion panel on SOA: a marketing buzz phrase past its prime. SOAP/HTTP web services remain the most robust solution even though simpler RESTful solutions have gained popularity on more ‘primitive’ platforms.

Finally an informal presentation by an engineering director and architect from LinkedIn describing their infrastructure and development practices. Tomcat, a custom MVC framework and JSP compiler, SpringRPC (~100 services), Jetty and Oracle on SPARC. Four million visitors a day peaking at 200,000 concurrent users. Originally pair programming but now simply at least two developers per project. No contractors, all 100 engineering staff in the same building. High end Mac workstations and laptops with Eclipse/IntelliJ. 1,500 JUnit/HttpUnit test cases for ~1,000 KLOC automated using Hudson. Database partitioned both vertically (by functional area) and horizontally (by member id range). Back to the hotel past 9pm.

Tuesday. Morning session Dean Warner on programming in Scala, a scary-powerful collision of Java and Lisp/Erlang used by Twitter for higly parallel message handling. Afternoon session with Chris Richardson, author of ‘POJOs in Action’ giving a technical introduction to Spring Framework dependency injection (replacing singletons with constructor arguments) enabling Spring AOP for service methods. Also Spring JDBC and Hibernate, all using either XML or annotations.

Wednesday. After two days of half-day tutorials the conference format switching to four 90 minute workshops per day plus lunchtime presentations. Website navigation using menus and search, especially for e-commerce. Overlay menus at Amazon. Everyone familiar with the layout of Outlook. making novel use of AJAX. Neal Ford with an introduction to Ruby and JRuby, an interpreted language well suited to metaprogramming such as building test frameworks including Mocha. Robert Martin walking through some of his code from FitNesse: functions should be well named, short, and do one thing only. Two presentations from Scott Ambler on Agile development: delivering code early and often, using TDD, involving stakeholders, building self-organizing teams and delivering what the customer wants. Geographically dispersed teams with a 15% higher rate of project failure: fly people around or pay more in hidden costs. Evening awards ceremony: Dr. Dobbs Excellence In Programming award going to Scott Meyers and over a dozen Jolt awards made in surprising haste, including easyb. Reading the first chapters of ‘Groovy In Action’.

Thursday. Morning sessions on how to select a web framework and testing web applications. Grails immature and questions still over the Groovy classloader. GWT-Ext and Tapestry 5 or Wicket a recommended configuration. Rod demonstrating unit and component testing tools, including infinitest, WicketTester, HtmlUnit and Watij. Lunchtime presentation from Juval Lowy on the coming boom in power management software for homes, electric vehicles and buildings. Afternoon sessions on Guice, a lightweight dependency injection framework, and using the new javax.script package in Java 6.

Friday. Morning sessions on Spring 3.0 and Continuous Testing. Spring Framework clearly mature and featureful. Rod demoing intellitest IDE plugin allowing all dependent unit tests in a project to be run automatically whenever class bytecode changed. Afternoon sessions on xUnit testing and generating documentation during the build cycle. Dependency injection does not require a framework for in-house applications. Creating and maintaining mock objects for database services may be impractical, consider the Dependent Object Framework and possibly H2 instead. Demos of Hudson and Doxygen rounding out the conference.

What did I get from the conference? Most inspriring was seeing Rod demonstrating TDD in action with a hands on pair programming session and discussions of the supporting tools. Scott Meyers, Robert Martin and Scott Ambler reinforcing the importance of TDD in the bigger picture, Justin Gordon describing use of TDD on a significant IBM project. Automated testing driving the adoption of dependency injection frameworks such as Spring and Guice. A second significant theme was scripting languages – including their use for testing – with sessions on Groovy/easyb, JRuby/Mocha and Scala. Finally there were the demos and pointers to projects like GWT-Ext, Hudson and Doxygen worthy of further investigation.

facelets-tutorial javax/el/ELResolverClass

ICEfaces have published a facelets-tutorial

Deployment instructions were limited so I downloaded and unzipped the source file into the samples folder provided with ICEfaces-1.7.2-SP1.

ant help
ant clean
ant tomcat6.0

I then copied dist/facelets-tutorial.war to tomcat-6.0/webapps… localhost…log showed:

Feb 21, 2009 11:11:07 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener
java.lang.LinkageError: loader constraints violated when linking javax/el/ELResolver class
 at com.sun.faces.config.ConfigureListener.registerELResolverAndListenerWithJsp(

Incompatibility between the EL included with ICEfaces and the EL provided with Tomcat 6? Stopping Tomcat, removing webapps/facelets-tutorial/web/WEB-INF/lib/el-api.jar and restarting provides a quick fix. Closer inspection of the facelets-tutorial build.xml reveals it has entries obsoleted by the newer version of samples/etc/build-common.xml and so is still including jars not needed or desired with Tomcat 6.

Trac on Solaris using Apache mod_python and https

If Trac is being used by a distributed team over the internet we want to remove all privileges from unauthenticated users:

  trac-admin $tracenv permission remove anonymous $perm
  trac-admin $tracenv permission add authenticated $perm

We also want to encrypt traffic to the site. To do this I tried stunnel…

/opt/csw/bin/pkg-get -i stunnel

…and placed the following in /opt/csw/etc/stunnel/stunnel.conf

accept  = 443
connect = 8000

I also commented out the chroot setup. Once configured all that is required is to run

cd /opt/csw/etc/stunnel 

…and change /var/opt/csw/trac/conf/trac.ini

authz_file =
authz_module_name =
base_url =

The bad news is that Trac 0.10.4 does not consistently use base_url, so creating a ticket, for example, redirects the user to an http page.

HTTPS=1; export HTTPS
nohup tracd --port 8000 $tracenv &

To resolve this issue I decided to move from tracd/stunnel to Apache2/mod_python. The default Solaris 10 distribution includes apache2 but not mod_python. Instead I installed mod_python from Blastwave, which in turn automatically installs the Blastwave cswapache2 package below /opt/csw/apache2.

pkg-get install ap2_modpython

We will want to run trac under apache2 using a dedicated account:

groupadd -g 202 trac
useradd -g trac -u 202 -d /var/opt/csw/trac trac
chown -R trac:trac /var/opt/csw/trac

Modified /opt/csw/apache2/etc/httpd.conf

User trac
Group trac
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

   SetHandler mod_python
   PythonInterpreter main_interpreter
   PythonHandler trac.web.modpython_frontend
   PythonOption TracEnv /var/opt/csw/trac

Created a self-signed certificate for the site:

cd /opt/csw/apache2/etc
/usr/sfw/bin/openssl genrsa -out server.key 2048
/usr/sfw/bin/openssl req -new -x509 -key server.key -out server.crt -days 365 -subj "/C=US/ST=Florida/O=My Company/"

Modified /opt/csw/apache2/etc/extra/httpd-ssl.conf


   SetHandler mod_python
   PythonInterpreter main_interpreter
   PythonHandler trac.web.modpython_frontend
   PythonOption TracEnv /var/opt/csw/trac

To start Blastwave Apache2 using SMF on Solaris:

svccfg -s cswapache2 setprop httpd/ssl=true
svccfg -s cswapache2 listprop

svcadm enable cswapache2

To check status

svcs cswapache2
svcs –xv

Trac on Solaris

Trac is a web-based software project management and bug/issue tracking system. Example publicly accessible sites that use Trac include

Getting Trac installed on Solaris 10 is easy, see Question is, what next?

Blastwave packages are installed below /opt/csw (csw = Community SoftWare). /opt/csw/share/doc/trac/INSTALL provides the next steps. I used:

trac-admin $tracenv initenv
tracd --port 8000 $tracenv & # no authentication
firefox http://localhost:8000/trac

For a small number of users the tracd standalone server is good enough. Authentication can be managed with htdigest on Solaris 10 thusly:

/usr/apache2/bin/htdigest -c $tracenv/conf/users.htdigest fred

Tracd can then be started like this:

nohup tracd --port 8000 --auth *,$tracenv/conf/users.htdigest, $tracenv &

To change the logo upload the new logo to /opt/csw/share/trac/htdocs and modify trac.ini

link =
src = common/mylogo.png
descr = My Trac
footer = Visit the Trac open source project at
icon = common/trac.ico
name = My Project
url =

Trac is much easier to administer with the WebAdmin plugin, which for Trac 0.10.4 requires downloading and installing from source:


To get started a Trac administrator has to be empowered:

trac-admin /var/opt/csw/trac permission add fred TRAC_ADMIN

To simplify account administration we’ll also try an account manger plugin


…and change /var/opt/csw/trac/conf/trac.ini

webadmin.* = enabled
trac.web.auth.LoginModule = disabled
acct_mgr.api = enabled
acct_mgr.htfile.HtDigestStore = enabled
acct_mgr.web_ui.AccountModule = enabled
acct_mgr.web_ui.LoginModule = enabled
acct_mgr.web_ui.RegistrationModule = disabled
acct_mgr.admin.AccountManagerAdminPage = enabled
password_format = htdigest
password_store = HtDigestStore
password_file = /var/opt/csw/trac/conf/users.htdigest
htdigest_realm =

Tracd can then be started like this:

nohup tracd --port 8000 $tracenv &

To manage custom fields we’ll add another plugin


…and change /var/opt/csw/trac/conf/trac.ini

customfieldadmin.* = enabled

Posts navigation

1 2 3 4 5 6
Scroll to top