By default, the Liferay platform does not define a SAXParser. But please note that a SAXParser contains the logic that can parse XML files.
Liferay does not define a SAXParser because certain setups (e.g. Weblogic) may already have a SAXParser; trying to override them with Liferay's own may cause serious issues. However, application servers, such as Tomcat, do not have their own SAXParser. So when working with Documents & Media, with S3Store and Liferay DXP 7.0 and 7.1, you will receive errors such as the following:
ERROR [http-nio-10080-exec-1][PortletServlet:109] javax.portlet.PortletException: com.amazonaws.AmazonClientException: Couldn't initialize a SAX driver to create an XMLReader
javax.portlet.PortletException: com.amazonaws.AmazonClientException: Couldn't initialize a SAX driver to create an XMLReader
org.xml.sax.SAXException: Can't create default XMLReader; is system property org.xml.sax.driver set? This error indicates that an XMLReader has not been defined.
Caused by: org.xml.sax.SAXException: SAX2 driver class org.apache.xerces.parsers.SAXParser not found_java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser cannot be found by com.liferay.journal.web_1.4.0 [Sanitized]
at org.xml.sax.helpers.XMLReaderFactory.loadClass(XMLReaderFactory.java:230)
at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(XMLReaderFactory.java:191)
at com.amazonaws.services.s3.model.transform.XmlResponsesSaxParser.<init>(XmlResponsesSaxParser.java:114)
... 229 more
Resolution
To resolve this issue, a SAXParser must be defined manually.
You can easily do this by setting one in a system-ext.properties file by executing the following steps:
- Create a
system-ext.propertiesfile - Add in
org.xml.sax.driver=com.sun.org.apache.xerces.internal.parsers.SAXParser - Place
system-ext.propertiesinto/webapps/$LIFERAY_WAR/WEB-INF/classes - Restart your DXP platform.
You should see the system-ext.properties load up in the starting logs, and you should not receive any SAXParser errors while working with S3Store.