Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: [LF7.4GA31] Portlet not showing in widget list when using @Reference
Hi,
we are starting to do some test on the Liferay 7.4 version, we noticed that portlet without any services works fine, instead portlet with services modules aren't working, the problem is that the portlet will not show up in widget list if we use @Reference(unbind = "-") to retrieve the service, for example with this code
private static CompetenzaLocalService _competenzaLocalService;
@Reference(unbind = "-")
protected void setCompetenzaLocalService(CompetenzaLocalService competenzaLocalService) {
_competenzaLocalService = competenzaLocalService;
}
Portlet won't show, instead with this code:
private static CompetenzaLocalService _competenzaLocalService;
protected void setCompetenzaLocalService(CompetenzaLocalService competenzaLocalService) {
_competenzaLocalService = competenzaLocalService;
}
it will show up in the widget list.
There aren't other errors, the portlet in both case correctly start
2022-07-06 13:00:25.597 INFO [pipe-start 1560][BundleStartStopLogger:77] STARTED it.tinfo.competenze_1.0.0 [1560]
in the app manager the status is active, also the portlet work fine in Liferay 7.3
Which could be the problem?
This typically means that the referenced service is not available - e.g. you'd need to also deploy the service-builder generated API and implementation bundle, and they'll need to start without any problems (the bundle may be active, but the service might have a problem).
If your widget appears in the list without the @Reference, the service won't be initialized, so you're likely running into NullpointerExceptions when you actually use your widget, whenever it tries to call the service.
Powered by Liferay™