Wednesday, January 18, 2012

Running Opatch throws up org.xml.sax.SAXParseException: : XML-20108: (Fatal Error) Start of root element expected

The server was hosting multiple Oracle homes from 10gR2, 11gR1 and 11gR2. Primarily used for testing PSU patch before applying to production system. There hasn't been any new installation of Oracle homes and inventory has been without any errors.

Trying to apply the PSU Jan threw up the following error.
Oracle Interim Patch Installer version
Copyright (c) 2011, Oracle Corporation.  All rights reserved.

Oracle Home       : /opt/app/oracle/product/11.2.0/ent11.2.0.3
Central Inventory : /opt/app/oraInventory
   from           : /opt/app/oracle/product/11.2.0/ent11.2.0.3/oraInst.loc
OPatch version    :
OUI version       :
Log file location : /opt/app/oracle/product/11.2.0/ent11.2.0.3/cfgtoollogs/opatch/opatch2012-01-18_12-16-37PM.log

org.xml.sax.SAXParseException: : XML-20108: (Fatal Error) Start of root element expected.
        at oracle.xml.parser.v2.XMLError.flushErrorHandler(
        at oracle.xml.parser.v2.XMLError.flushErrors1(
        at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(
        at oracle.xml.parser.v2.NonValidatingParser.parseDocument(
        at oracle.xml.parser.v2.XMLParser.parse(
        at oracle.sysman.oii.oiii.OiiiOracleHomeInfoXMLReader.updateHomeProperties(
        at oracle.sysman.oii.oiii.OiiiInstallInventory.updateOracleHomesProperties(
        at oracle.sysman.oii.oiii.OiiiInstallInventory.updateOracleHomesProperties(
        at oracle.sysman.oii.oiii.OiiiInstallInventory.readHomes(
        at oracle.sysman.oii.oiii.OiiiInstallAreaControl.loadPartialInstallInv(
        at oracle.sysman.oii.oiii.OiiiInstallAreaControl.initInstallInv(
        at oracle.sysman.oii.oiii.OiiiInstallAreaControl.loadInstallInventory(
        at oracle.sysman.oii.oiii.OiiiInstallAreaControl.initAreaControl(
        at oracle.sysman.oii.oiii.OiiiInstallAreaControl.initAreaControl(
        at oracle.sysman.oii.oiic.OiicStandardInventorySession.initSession(
        at oracle.sysman.oii.oiic.OiicStandardInventorySession.initSession(
        at oracle.sysman.oii.oiic.OiicStandardInventorySession.initSession(
        at oracle.opatch.OUIInventorySession.initSession(
        at oracle.opatch.OUISessionManager.setupSession(
        at oracle.opatch.OUISessionManager.lockCentralInventory(
        at oracle.opatch.OUISessionManager.instantiate(
        at oracle.opatch.OUISessionManager.updateOPatchEnvironment(
        at oracle.opatch.InventorySessionManager.updateOPatchEnvironment(
        at oracle.opatch.OPatchSession.main(
        at oracle.opatch.OPatch.main(
No matter which Oracle home was choosen the same error came up.

Two metalink notes related to the issue are
OPatch Is Failing With "org.xml.sax.SAXParseException" XML-20108: (Fatal Error) [ID 1365569.1]
Opatch command throws warning:org.xml.sax.SAXParseException: : XML-20108: (Fatal Error) Start of root element expected. [ID 1344580.1]

Issue mentioned in the first metalink note isn't the case here as the opatch version matches the oracle home version.
The second one mentions if $ORACLE_HOME/inventory/ContentsXML/oraclehomeproperties.xml file is 0 bytes then this error is shown. But the size of this file in the oracle home wasn't 0 bytes
ls -l $ORACLE_HOME/inventory/ContentsXML/oraclehomeproperties.xml
-rw-rw---- 1 oracle oinstall 526 Nov 16 14:20 /opt/app/oracle/product/11.2.0/ent11.2.0.3/inventory/ContentsXML/oraclehomeproperties.xml
It seemed the cause mentioned in the second metalink note is also not the case. But checking all the homes in the server it was found that there was one oracle home (home running 11gR1) which had this file with 0 bytes. There was a cloned copy of this home on which the file wasn't 0 bytes. Copying it into the this oracle home's inventory/ContentsXML resolved this issue.

Therefore when there are multiple oracle homes in a server and if inventory/ContentsXML/oraclehomeproperties.xml file gets corrupted in at least one of them the opatch will throw the above mentioned XML parse error.