legacy-knowledge-base
公開されました Sep. 10, 2025

ドキュメントとメディアにドキュメントを追加する際に、ドキュメントの保存中に予期せぬエラーが発生しました。

written-by

Ricardo Couso

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

legacy-article

learn-legacy-article-disclaimer-text

問題

  • 個人または複数の文書を「ドキュメントとメディア」に追加しようとすると、エラーが発生します: 文書の保存中に予期せぬエラーが発生しました.

Environment

  • Liferay DXP 7.3, 7.4

解決策

  • このエラーは、 dlfolder のテーブルで以前に削除があり、意図せず必要なエントリーが削除された場合に発生する可能性があります。
  • この現象は、API DLApp*の代わりに、API DLFolder* を使用した場合に発生する可能性があります(ドキュメントで説明): Documents and Media APIで説明されています。
  • 問題は、テーブル リポジトリ に、存在しない dlFolderId'sを指すオーファンエントリーができてしまうことです。
  • データベースの整合性を回復するために、このスクリプトを実行してください:
    //  This script was created to restore database consistency after 
    // unintentionally deleting necessary entries from the dlFolder table. // The repository table has orphaned entries pointing to nonexisting
    // dlFolderId's.
    // Note: This script has a flag to execute in safe mode.
    // By default, runDry = true is set to allow users to check if
    // entries appearing in the log correspond to orphaned entries
    // pointing to nonexisting dlFolderId's. import com.liferay.portal.kernel.service.RepositoryLocalServiceUtil; import com.liferay.portal.kernel.model.Repository; import com.liferay.portal.kernel.dao.jdbc.DataAccess; import com.liferay.portal.kernel.util.PortalUtil; import java.io.IOException; import java.io.PrintWriter; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; boolean runDry = true; Connection con = null; PreparedStatement ps = null; ResultSet rs = null; if (runDry) { out.println("Executing in save mode. No removals will be performed."); } try { con = DataAccess.getConnection(); String sql = "select repositoryId from repository
    where name like 'com.liferay.portal.kernel.util.TempFileEntryUtil'
    and dlFolderId not in (select folderId from dlfolder);"; sql = PortalUtil.transformSQL(sql); ps = con.prepareStatement(sql); rs = ps.executeQuery(); int rows = 0; while (rs.next()) { long repositoryId = rs.getLong(1); if (!runDry) { try { RepositoryLocalServiceUtil.deleteRepository(repositoryId); out.println("Succesfully deleted repository: " + repositoryId); } catch(Exception e) { e.printStackTrace(out); } } else { out.println("RepositoryId " + repositoryId + " would be removed."); } rows++; } if (!runDry) { out.println(rows + " rows have been removed."); } else { out.println(rows + " rows would have been removed."); } } catch(Exception e) { e.printStackTrace(out); }
did-this-article-resolve-your-issue

legacy-knowledge-base