Legacy Knowledge Base
公開されました Jun. 30, 2025

サービスビルダー:参照されるエンティティのシンボル *LocalService が見つかりません。

Written By

Jose L. Bango

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

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

問題

  • 製品の最新バージョンをターゲットにした後、FooLocalServiceBaseImplクラスに注入された@Referenceに対して 'cannot find symbol' エラーが発生する場合があります。 こんな感じだ:
    error: cannot find symbol
    protected com.liferay.asset.kernel.service.AssetLinkLocalService
  • この例では、エンティティのservice.xmlは以下のようになる:
    <reference entity="AssetLink" package-path="com.liferay.portlet.asset" />

環境

  • Liferay Workspace

解像度

  • これは、参照されているエンティティが別のパッケージ(おそらくカーネルからOSGiモジュールへ)に移動した場合に発生する可能性がある。
  • プロジェクトコードで参照されているエンティティを検索することで、それがあなたのケースであるかどうかを確認することができます。
  • そのような場合は、次のような方法がある:
    • エンティティのservice.xmlから、その<参照>を削除する。
    • 代わりに、@Referenceアノテーションを使用して、FooLocalServiceImplから目的の*LocalServiceクラスを参照します。
    • これは製品内部で行われてきたことだ。 アセットリンクのモジュール化を例にとれば:
  • なお、パッケージパスを変更しただけでは、以下のようなエラーが発生する:
    Unable to find AssetLink in Foo
    Example in thread "main" com.liferay.portal.tools.service.builder.ServiceBuilderException:Unable to find AssetLink in Foo
    at com.liferay.portal.tools.service.builder.ServiceBuilder.getEntity(ServiceBuilder.java:1244)
    at com.liferay.portal.tools.service.builder.ServiceBuilder._resolveEntity(ServiceBuilder.
    at com.liferay.portal.tools.service.builder.ServiceBuilder._resolveEntity(ServiceBuilder.java:8000)<init>(ServiceBuilder.java:805)
    at com.liferay.portal.tools.service.builder.ServiceBuilder.main(ServiceBuilder.java:234)
    Caused by: java.io.IOException:Unable to open resource com/liferay/asset/link/service.xml in class loader sun.misc.Launcher$AppClassLoader@1b6d3586
    at com.liferay.portal.kernel.util.StringUtil.read(StringUtil.java:2286)
    at com.liferay.portal.kernel.util.StringUtil.read(StringUtil.java:2254)
    at com.liferay.portal.tools.service.builder.ServiceBuilder.getEntity(ServiceBuilder.java:1239)
    • 別の記事で紹介している別の方法を使うこともできる。

追加情報

Did this article resolve your issue ?

Legacy Knowledge Base