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

カスタム開発で util-java のクラスを使用する未解決の要件

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

問題

  • build.gradle 依存関係を追加することにより、カスタム開発で com.liferay.util.Normalizerなどの /util-javaからのクラスを使用しようとしています
    compileOnly group: "com.liferay.portal", name: "com.liferay.util.java"
    次のような未解決の要件につながります。
    2021-08-19 09:56:31.228 ERROR [fileinstall-directory-watcher][DirectoryWatcher:1139] Unable to start bundle: file:[...]/testportlet-1.0.0.jar
    org.osgi.framework.BundleException: Could not resolve module: test.sample.versions [1591]_  Unresolved requirement: Import-Package: com.liferay.util; version="[10.0.0,11.0.0)"_ [Sanitized]
        at org.eclipse.osgi.container.Module.start(Module.java:444)
        at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:428)
        at com.liferay.portal.file.install.internal.DirectoryWatcher._startBundle(DirectoryWatcher.java:1122)
        at com.liferay.portal.file.install.internal.DirectoryWatcher._startBundles(DirectoryWatcher.java:1155)
        at com.liferay.portal.file.install.internal.DirectoryWatcher._startAllBundles(DirectoryWatcher.java:1100)
        at com.liferay.portal.file.install.internal.DirectoryWatcher._process(DirectoryWatcher.java:1012)
        at com.liferay.portal.file.install.internal.DirectoryWatcher.run(DirectoryWatcher.java:265)

Environment

  • Liferay DXP 7.3

解決策

  • この未解決の要件を修正するには、ファイル bnd.bndに要件と関連する依存関係を明示的に含める必要があります。
  • 上記の例では、 bnd.bnd に含める追加の行は次のようになります。
    Include-Resource: @com.liferay.util.java-[0-9.]*.jar
    Import-Package: \
        !net.fortuna.ical4j.model,\
        !net.fortuna.ical4j.model.property,\
        !org.apache.axis.tools.ant.wsdl,\
        !org.apache.poi.hssf.usermodel,\
        !org.apache.poi.ss.usermodel,\
        *
  • これを簡素化するための機能要求があります: LPS-137726 開発者として、util-java のクラスをより簡単に使用したい
did-this-article-resolve-your-issue

legacy-knowledge-base