Legacy Knowledge Base
Published Jun. 30, 2025

Service Builder: Cannot find symbol *LocalService for referenced entity

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.

Issue

  • After targeting a more recent version of the product, you may get a 'cannot find symbol' error for an injected @Reference in your FooLocalServiceBaseImpl class. Something like this:
    error: cannot find symbol
    protected com.liferay.asset.kernel.service.AssetLinkLocalService
  • For this example, your entity's service.xml would look like this:
    <reference entity="AssetLink" package-path="com.liferay.portlet.asset" />

Environment

  • Liferay Workspace

Resolution

  • This can happen if the referenced entity has been moved to a diferent package (likely from the kernel to an OSGi module).
  • You can check if that's your case by searching for the referenced entity in the project code.
  • If that is your case, you can follow the following approach:
    • Remove that <reference> from your entity's service.xml.
    • Instead, reference the desired *LocalService class from your FooLocalServiceImpl using the @Reference annotation.
    • This is what has been done internally in the product. If we use the AssetLink modularization as an example:
  • Note that you will get the following error in case you just change the package-path for the new one: 
    Unable to find AssetLink in Foo
    Exception 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.java:8000)
    at com.liferay.portal.tools.service.builder.ServiceBuilder.<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)

Additional Information

Did this article resolve your issue ?

Legacy Knowledge Base