Category: Database

  • No implementation defined for org.apache.commons.logging.LogFactory

    While writing a DB2 stored procedure that invoked a SOAP/WSDL web service using Apache Axis as part of WSIF, I ran into this doozie:

    org.apache.commons.discovery.DiscoveryException:
    No implementation defined for org.apache.commons.logging.LogFactory

    Ultimately, it’s caused by a too restrictive lib/security/java.policy file that ships with DB2.

    Wrong Solution

    The standard way to define an implementation is to create the following commons-logging.properties file and place it anywhere in your CLASSPATH (such as the root of a JAR file):

    # Default
    #org.apache.commons.logging.LogFactory = org.apache.commons.logging.impl.LogFactoryImpl
    
    # SimpleLog
    #org.apache.commons.logging.Log = org.apache.commons.logging.impl.SimpleLog 
    
    # JDK 1.4 logger
    #org.apache.commons.logging.Log = org.apache.commons.logging.impl.Jdk14Logger
    
    # Avalon Toolkit
    #org.apache.commons.logging.Log = org.apache.commons.logging.impl.LogKitLogger
    
    # Log4j (Recommended by Axis)
    org.apache.commons.logging.Log = org.apache.commons.logging.impl.Log4JLogger

    Alternatively, you can set the org.apache.commons.logging.Log configuration attribute for LogFactory programmatically.

    Right Solution

    Solution: Running an Axis SOAP client in Domino [or DB2]

    My DB2 is installed into C:Program FilesIBMSQLLIB

    1. Copy all your JARs to C:Program FilesIBMSQLLIBjavajdkjrelibext
    2. Open C:Program FilesIBMSQLLIBjavajdkjrelibsecurity
    3. Open java.policy
    4. Add:

    permission java.util.PropertyPermission "java.protocol.handler.pkgs", "write";

    5. Restart DB2

  • Unexpected for following namespace declaration

    I ran into a problem running a simple test xquery. I hadn’t directly dealt with XML namespaces in xquery prior to this, but the documentation was clear enough:

    XQUERY
    declare default element namespace "http://posample.org"
    for $x in db2-fn:xmlcolumn("PURCHASEORDER.PORDER")
    return $x

    Oops, EOF error. It needs a terminator.

    XQUERY
    declare default element namespace "http://posample.org"
    for $x in db2-fn:xmlcolumn("PURCHASEORDER.PORDER")
    return $x;

    Unexpected “for” following the namespace declaration? Pardon? It turns out xquery prologs need to be terminated by a semicolon:

    XQUERY
    declare default element namespace "http://posample.org";
    for $x in db2-fn:xmlcolumn("PURCHASEORDER.PORDER")
    return $x;

    Unexpected “http://posample.org”? But that’s the exact syntax given in the examples! Alas, this semicolon is distinct from the usual semicolon separator in SQL. It’s part of a single xquery statement, so what I need to do is change the SQL separator to something more exotic. This will allow xquery to be parsed correctly:

    XQUERY
    declare default element namespace "http://posample.org";
    for $x in db2-fn:xmlcolumn("PURCHASEORDER.PORDER")
    return $x@

    Eureka.:)

  • Mapping DB2 databases after a reinstall

    Due to the vagaries of software, I had to reinstall DB2 on my laptop. Unfortunately, the existing databases were not automatically added to the Control Center.

    Physically, DB2 stores its databases in a directory similar to C:DB2NODE0000. Logically, there must a way to remap them. So, how does one remap them?

    To list databases stored at a path:
    % db2 list db directory on c:

    To recatalog them:
    % db2 catalog db SAMPLE on c:

    Reference:
    DB2 at a Glance | The DB2 Environment

  • WinSCP

    Sometimes I develop on Linux, sometimes on Windows. It’s mostly Windows right now. I tend towards editing with UltraEdit (or the free Crimson Editor, uploading with WinSCP, and doing command-line stuff with Cygwin. If you just want ssh (new-fangled telnet), PuTTY is easier to get working.

    If I keep doing PHP stuff, I might end up switching to the Eclipse PHP IDE. Stranger things have happenned.

    There’s a list of useful Windows software on my wiki.