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: OSGI unsatisfied reference
Hi All,I tried to do custom finder method according to https://portal.liferay.dev/docs/7-2/appdev/-/knowledge_base/a/defining-a-custom-finder-method . After that there is OSGI unsatisfied reference error is coming as per following. Any one please suggest how should i solve for the issue. I am using liferay 7.2 GA1. Thank you
Component Description: com.liferay.docs.guestbook.service.impl.GuestbookLocalServiceImpl
========================================================================================
Class: com.liferay.docs.guestbook.service.impl.GuestbookLocalServiceImpl
Bundle: 120 (com.liferay.docs.guestbook.service:1.0.0)
Enabled: true
Immediate: false
Services: [com.liferay.portal.aop.AopService]
Scope: singleton
Config PID(s): [com.liferay.docs.guestbook.service.impl.GuestbookLocalServiceImpl], Policy: optional
Base Props: (1 entry)
model.class.name<String> = com.liferay.docs.guestbook.model.GuestbookComponent Configuration Id: 5043
--------------------------------
State: UNSATISFIED REFERENCE
Config Props: (3 entries)
component.id<Long> = 5043
component.name<String> = com.liferay.docs.guestbook.service.impl.GuestbookLocalServiceImpl
model.class.name<String> = com.liferay.docs.guestbook.model.Guestbook
References: (total 7)
- guestbookFinder: com.liferay.docs.guestbook.service.persistence.GuestbookFinder UNSATISFIED 1..1 static
target=(*) scope=bundle
- classNameLocalService: com.liferay.portal.kernel.service.ClassNameLocalService SATISFIED 1..1 static
target=(*) scope=bundle (no active bindings)
- counterLocalService: com.liferay.counter.kernel.service.CounterLocalService SATISFIED 1..1 static
target=(*) scope=bundle (no active bindings)
- guestbookEntryPersistence: com.liferay.docs.guestbook.service.persistence.GuestbookEntryPersistence SATISFIED 1..1 s
tatic
target=(*) scope=bundle (no active bindings)
- guestbookPersistence: com.liferay.docs.guestbook.service.persistence.GuestbookPersistence SATISFIED 1..1 static
target=(*) scope=bundle (no active bindings)
- resourceLocalService: com.liferay.portal.kernel.service.ResourceLocalService SATISFIED 1..1 static
target=(*) scope=bundle (no active bindings)
- userLocalService: com.liferay.portal.kernel.service.UserLocalService SATISFIED 1..1 static
target=(*) scope=bundle (no active bindings)
g!
g!
Component Description: com.liferay.docs.guestbook.service.impl.GuestbookLocalServiceImpl
========================================================================================
Class: com.liferay.docs.guestbook.service.impl.GuestbookLocalServiceImpl
Bundle: 120 (com.liferay.docs.guestbook.service:1.0.0)
Enabled: true
Immediate: false
Services: [com.liferay.portal.aop.AopService]
Scope: singleton
Config PID(s): [com.liferay.docs.guestbook.service.impl.GuestbookLocalServiceImpl], Policy: optional
Base Props: (1 entry)
model.class.name<String> = com.liferay.docs.guestbook.model.GuestbookComponent Configuration Id: 5043
--------------------------------
State: UNSATISFIED REFERENCE
Config Props: (3 entries)
component.id<Long> = 5043
component.name<String> = com.liferay.docs.guestbook.service.impl.GuestbookLocalServiceImpl
model.class.name<String> = com.liferay.docs.guestbook.model.Guestbook
References: (total 7)
- guestbookFinder: com.liferay.docs.guestbook.service.persistence.GuestbookFinder UNSATISFIED 1..1 static
target=(*) scope=bundle
- classNameLocalService: com.liferay.portal.kernel.service.ClassNameLocalService SATISFIED 1..1 static
target=(*) scope=bundle (no active bindings)
- counterLocalService: com.liferay.counter.kernel.service.CounterLocalService SATISFIED 1..1 static
target=(*) scope=bundle (no active bindings)
- guestbookEntryPersistence: com.liferay.docs.guestbook.service.persistence.GuestbookEntryPersistence SATISFIED 1..1 s
tatic
target=(*) scope=bundle (no active bindings)
- guestbookPersistence: com.liferay.docs.guestbook.service.persistence.GuestbookPersistence SATISFIED 1..1 static
target=(*) scope=bundle (no active bindings)
- resourceLocalService: com.liferay.portal.kernel.service.ResourceLocalService SATISFIED 1..1 static
target=(*) scope=bundle (no active bindings)
- userLocalService: com.liferay.portal.kernel.service.UserLocalService SATISFIED 1..1 static
target=(*) scope=bundle (no active bindings)
g!
g!
Hi Everyone,Any suggestion? Thank you
So this line:
guestbookFinder: com.liferay.docs.guestbook.service.persistence.GuestbookFinder UNSATISFIED 1..1 static target=(*) scope=bundle
This tells you that your GuestbookLocalServiceImpl has an @Reference dependency on a GuestbookFinder, but it is not finding one.
So this points to your GuestbookFinder not starting and/or not registering. Do you have this corresponding info on the GuestbookFinder? Can you share some or all of your GuestbookFinder class?
guestbookFinder: com.liferay.docs.guestbook.service.persistence.GuestbookFinder UNSATISFIED 1..1 static target=(*) scope=bundle
This tells you that your GuestbookLocalServiceImpl has an @Reference dependency on a GuestbookFinder, but it is not finding one.
So this points to your GuestbookFinder not starting and/or not registering. Do you have this corresponding info on the GuestbookFinder? Can you share some or all of your GuestbookFinder class?
Hi David,
Please see the attached for all source code.
Yes, correct and agree that GuestbookLocalServiceImpl has an @Reference dependency on a GuestbookFinder and can't find.
guestbookFinder.findByEntryNameEntryMessageGuestbookName(entryName, entryMessage,guestbookName, begin, end); is calling within GuestbookEntryLocalServiceImpl .
Please suggest how should i fix it. I am using liferay 7.2 GA1. I also attached web portlet as well. Thank you
Please see the attached for all source code.
Yes, correct and agree that GuestbookLocalServiceImpl has an @Reference dependency on a GuestbookFinder and can't find.
guestbookFinder.findByEntryNameEntryMessageGuestbookName(entryName, entryMessage,guestbookName, begin, end); is calling within GuestbookEntryLocalServiceImpl .
Please suggest how should i fix it. I am using liferay 7.2 GA1. I also attached web portlet as well. Thank you
Attachments:
You cannot @Reference a class that is not itself an @Component.
Your GuestbookFinderImpl is not an @Component, so OSGi has nothing to inject.
Your GuestbookFinderImpl is not an @Component, so OSGi has nothing to inject.
Thank you so much David,
Firstly i tried to put @Component in GuestbookFinderImpl but it is also fail. Finally i changed following without using @Reference and it is working.
From GuestbookFinderImpl class
---------------------------------------------------
String sql = CustomSQLUtil.get(
// String sql = _customSQL.get(
getClass(),
FIND_BY_ENTRYNAME_ENTRYMESSAGE_GUESTBOOKNAME);
// @Reference
// private CustomSQL _customSQL;
From build.gradle
-------------------------------
compileOnly group: 'com.liferay', name: 'com.liferay.portal.dao.orm.custom.sql', version: '1.0.22'
runtime group: 'com.liferay', name: 'com.liferay.portal.dao.orm.custom.sql', version: '1.0.22'
from bnd.bnd
-------------------------------
Import-Package: \ *
-includeresource: \ @com.liferay.portal.dao.orm.custom.sql-1.0.22.jar
from service.xml--------------------------dependency-injector use with spring. Earlier with ds. <service-builder dependency-injector="spring" package-path="com.liferay.docs.guestbook" mvcc-enabled="true">
Firstly i tried to put @Component in GuestbookFinderImpl but it is also fail. Finally i changed following without using @Reference and it is working.
From GuestbookFinderImpl class
---------------------------------------------------
String sql = CustomSQLUtil.get(
// String sql = _customSQL.get(
getClass(),
FIND_BY_ENTRYNAME_ENTRYMESSAGE_GUESTBOOKNAME);
// @Reference
// private CustomSQL _customSQL;
From build.gradle
-------------------------------
compileOnly group: 'com.liferay', name: 'com.liferay.portal.dao.orm.custom.sql', version: '1.0.22'
runtime group: 'com.liferay', name: 'com.liferay.portal.dao.orm.custom.sql', version: '1.0.22'
from bnd.bnd
-------------------------------
Import-Package: \ *
-includeresource: \ @com.liferay.portal.dao.orm.custom.sql-1.0.22.jar
from service.xml--------------------------dependency-injector use with spring. Earlier with ds. <service-builder dependency-injector="spring" package-path="com.liferay.docs.guestbook" mvcc-enabled="true">