RE: [LF7.4GA31] Portlet not showing in widget list when using @Reference

Tinfo Tinfo, modified 3 Years ago. New Member Posts: 14 Join Date: 5/14/20 Recent Posts

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?

thumbnail
Olaf Kock, modified 3 Years ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts

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.