Issue
- During your upgrade process, you might encounter an error during the
com.liferay.journal.internal.upgrade.v1_1_0.DocumentLibraryTypeContentUpgradeProcess
step:
Caused by: com.liferay.portal.kernel.xml.DocumentException: Error on line 12 of document : The reference to entity "S" must end with the ';' delimiter.
at com.liferay.portal.xml.SAXReaderImpl.read(SAXReaderImpl.java:409) ~[portal-impl.jar:?]
at com.liferay.portal.xml.SAXReaderImpl.read(SAXReaderImpl.java:383) ~[portal-impl.jar:?]
at com.liferay.portal.xml.SAXReaderImpl.read(SAXReaderImpl.java:420) ~[portal-impl.jar:?]
at com.liferay.portal.kernel.xml.SAXReaderUtil.read(SAXReaderUtil.java:161) ~[portal-kernel.jar:?]
at com.liferay.journal.internal.upgrade.v1_1_0.DocumentLibraryTypeContentUpgradeProcess._convertContent(DocumentLibraryTypeContentUpgradeProcess.java:49) ~[?:?]
at com.liferay.journal.internal.upgrade.v1_1_0.DocumentLibraryTypeContentUpgradeProcess._updateContent(DocumentLibraryTypeContentUpgradeProcess.java:91) ~[?:?]
at com.liferay.journal.internal.upgrade.v1_1_0.DocumentLibraryTypeContentUpgradeProcess.doUpgrade(DocumentLibraryTypeContentUpgradeProcess.java:45) ~[?:?]
at com.liferay.portal.kernel.upgrade.UpgradeProcess.lambda$upgrade$0(UpgradeProcess.java:130) ~[portal-kernel.jar:?]
at com.liferay.portal.db.partition.DBPartitionUtil.forEachCompanyId(DBPartitionUtil.java:126) ~[portal-impl.jar:?]
at com.liferay.portal.dao.db.BaseDB.process(BaseDB.java:337) ~[portal-impl.jar:?]
at com.liferay.portal.kernel.dao.db.BaseDBProcess.process(BaseDBProcess.java:387) ~[portal-kernel.jar:?]
at com.liferay.portal.kernel.upgrade.UpgradeProcess.upgrade(UpgradeProcess.java:115) ~[portal-kernel.jar:?]
...
- This error is thrown when an XML document has errors, such as a tag is not closed or mistyped, etc.
- The mentioned upgrade step is querying Web Contents (Journal Articles) which are contains a Document Library field.
- The error indicates that you have one or multiple Web Contents with a Document Library field where the content XML of the Web Content has issues
Environment
- Liferay DXP 7.4
Resolution
- With the following query, you can check the rows:
select content, id_ from JournalArticle where content like '%type=\"document_library\"%';
- You can run the attached groovy script to validate the listed rows
import com.liferay.portal.kernel.xml.SAXReaderUtil;
import com.liferay.portal.kernel.xml.Document;
import com.liferay.journal.model.JournalArticle;
import com.liferay.journal.service.JournalArticleLocalServiceUtil;
import com.liferay.portal.kernel.dao.jdbc.DataAccess;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
Logger logger = LoggerFactory.getLogger(com.liferay.portal.scripting.groovy.internal.GroovyExecutor.class);
logger.info("Starting validating web content XMLs...");
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
con = DataAccess.getConnection();
String statement = "select id_ from JournalArticle where content like " +
"'%type=\"document_library\"%'";
ps = con.prepareStatement(statement);
rs = ps.executeQuery();
List<Long> articleIds = new ArrayList<>();
List<Long> invalidArticleIds = new ArrayList<>();
while(rs.next()) {
articleIds.add(rs.getLong("id_"));
}
for(long articleId : articleIds) {
JournalArticle article = JournalArticleLocalServiceUtil.getArticle(articleId);
String content = article.getContent();
try {
Document document = SAXReaderUtil.read(content);
} catch (Exception e) {
invalidArticleIds.add(articleId);
}
}
if(invalidArticleIds.size() > 0) {
logger.info("The articles with the following IDs have issues in their content XML (" + invalidArticleIds.size() + " in total):");
for(long articleId : invalidArticleIds) {
logger.info((String)articleId);
}
} else {
logger.info("All of the specified articles' content XMLs are valid.");
}
} catch (Exception e) {
logger.info("Failed to read the articles from the database " + e.printStackTrace());
} finally {
DataAccess.cleanUp(con, ps, rs);
}
logger.info("Script is finished."); - Once you have the faulty ones, you should make sure that the XML values are fixed
Subscriber Exclusive Content
A Liferay Enterprise Subscription provides access to over 1,500 articles that include best practices, troubleshooting, and other valuable solutions. Sign in for full access.
Sign In