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 11.2.0.1.9
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    : 11.2.0.1.9
OUI version       : 11.2.0.3.0
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(XMLError.java:415)
        at oracle.xml.parser.v2.XMLError.flushErrors1(XMLError.java:284)
        at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:331)
        at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:293)
        at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:209)
        at oracle.sysman.oii.oiii.OiiiOracleHomeInfoXMLReader.updateHomeProperties(OiiiOracleHomeInfoXMLReader.java:86)
        at oracle.sysman.oii.oiii.OiiiInstallInventory.updateOracleHomesProperties(OiiiInstallInventory.java:803)
        at oracle.sysman.oii.oiii.OiiiInstallInventory.updateOracleHomesProperties(OiiiInstallInventory.java:781)
        at oracle.sysman.oii.oiii.OiiiInstallInventory.readHomes(OiiiInstallInventory.java:737)
        at oracle.sysman.oii.oiii.OiiiInstallAreaControl.loadPartialInstallInv(OiiiInstallAreaControl.java:776)
        at oracle.sysman.oii.oiii.OiiiInstallAreaControl.initInstallInv(OiiiInstallAreaControl.java:821)
        at oracle.sysman.oii.oiii.OiiiInstallAreaControl.loadInstallInventory(OiiiInstallAreaControl.java:592)
        at oracle.sysman.oii.oiii.OiiiInstallAreaControl.initAreaControl(OiiiInstallAreaControl.java:1977)
        at oracle.sysman.oii.oiii.OiiiInstallAreaControl.initAreaControl(OiiiInstallAreaControl.java:1930)
        at oracle.sysman.oii.oiic.OiicStandardInventorySession.initSession(OiicStandardInventorySession.java:301)
        at oracle.sysman.oii.oiic.OiicStandardInventorySession.initSession(OiicStandardInventorySession.java:240)
        at oracle.sysman.oii.oiic.OiicStandardInventorySession.initSession(OiicStandardInventorySession.java:189)
        at oracle.opatch.OUIInventorySession.initSession(OUIInventorySession.java:63)
        at oracle.opatch.OUISessionManager.setupSession(OUISessionManager.java:150)
        at oracle.opatch.OUISessionManager.lockCentralInventory(OUISessionManager.java:267)
        at oracle.opatch.OUISessionManager.instantiate(OUISessionManager.java:87)
        at oracle.opatch.OUISessionManager.updateOPatchEnvironment(OUISessionManager.java:661)
        at oracle.opatch.InventorySessionManager.updateOPatchEnvironment(InventorySessionManager.java:91)
        at oracle.opatch.OPatchSession.main(OPatchSession.java:1661)
        at oracle.opatch.OPatch.main(OPatch.java:653)
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.