掲示板
Service are not getting registered in OSGI container
6年前 に krishna mohan mathakala によって更新されました。
Service are not getting registered in OSGI container
Junior Member 投稿: 68 参加年月日: 12/09/08 最新の投稿
Hi I have created a service builder module Employee-Services, which build successfully and it is active (both api and service).
I have created a Employee-web portlet module. In portlets build.gradle I have configured the service builder api as dependency shown below.
In my portlets controller I have accessed
When I deploy my Employee-web portlet module it is also build successfully and it is in active state.
When I added the portlet to a page, I got the null pointer exception in class
So In my portlet I added the below code to avoid calling the method of EmployeeLocalServiceUtil
and instead of
When I deploy my portlet, It is in active state. But It does not appear on the portal page.
On gogo shell I typed
Output:
and also I tested the below command
inspect cap service 1279(bundle Id)
output is :
it seems no services are registered in the osgi container.
Environment details :
Server : Weblogic 12c R2
Database : Mysql 5.7
Java 8
I have created a Employee-web portlet module. In portlets build.gradle I have configured the service builder api as dependency shown below.
compileOnly project(":modules:Employee-Services:Employee-Services-api")
In my portlets controller I have accessed
EmployeeLocalServiceUtil.getEmployeeNames();
method.When I deploy my Employee-web portlet module it is also build successfully and it is in active state.
When I added the portlet to a page, I got the null pointer exception in class
EmployeeLocalServiceUtil
at linereturn getService().methodname();
So In my portlet I added the below code to avoid calling the method of EmployeeLocalServiceUtil
@Reference
private EmployeeLocalService employeeLocalService
and instead of
EmployeeLocalServiceUtil.getEmployeeNames()
I used employeeLocalService.getEmployeeNames()
When I deploy my portlet, It is in active state. But It does not appear on the portal page.
On gogo shell I typed
g! dm wtf
Output:
No missing dependencies found.
g!
and also I tested the below command
inspect cap service 1279(bundle Id)
g! inspect cap service 1279
output is :
com.test.employee.api_1.0.0 [1279] provides:
---------------------------------------------------
service [EMPTY]
g!
it seems no services are registered in the osgi container.
Environment details :
Server : Weblogic 12c R2
Database : Mysql 5.7
Java 8
6年前 に Ketan Solanki によって更新されました。
RE: Service are not getting registered in OSGI container
Junior Member 投稿: 63 参加年月日: 14/05/28 最新の投稿
Hi,
I am stuck in the same thing, I guess.
I have followed this Developing a Web Application and have gone till Leveraging Search smoothly.
Now that when I deploy guestbook-api, guesbook-service, those are deployed fine. Then I deployed guestbook-web and that deployment goes fine too. But somehow when I invoke portlet, portlet is not working fine.
REASON:
But when I comment out the @Reference(unbind = "-"), portlet comes up perfectly fine - though it won't work and will throw NPE
Meaning, somehow class' (EntryLocalService, GuestbookLocalService )instances are not created/registered in OSGi and hence not getting injected to the portlet class.
I am not sure what's wrong here! I have simply followed the document and I was hoping it should have worked fine but not. I am new to OSGi framework. I was expecting both of those classes to have @Component annotation but they have got @ProviderType annotation!
I have gone through blog to know more about ProviderType, but couldn't gather much from that too.
@Krishna: We both have hit the same roadblock, need to find a solution. I will post here if I get something, you too please do the same.
EDIT:
I just checked the inspect cap service command for guesbook-api and guestbook-service, they DO NOT return the expected services
Thanks
Ketan
I am stuck in the same thing, I guess.
I have followed this Developing a Web Application and have gone till Leveraging Search smoothly.
Now that when I deploy guestbook-api, guesbook-service, those are deployed fine. Then I deployed guestbook-web and that deployment goes fine too. But somehow when I invoke portlet, portlet is not working fine.
REASON:
@Reference(unbind = "-")
protected void setEntryService(EntryLocalService entryLocalService) {
_entryLocalService = entryLocalService;
}
@Reference(unbind = "-")
protected void setGuestbookService(GuestbookLocalService guestbookLocalService) {
_guestbookLocalService = guestbookLocalService;
}
But when I comment out the @Reference(unbind = "-"), portlet comes up perfectly fine - though it won't work and will throw NPE
Meaning, somehow class' (EntryLocalService, GuestbookLocalService )instances are not created/registered in OSGi and hence not getting injected to the portlet class.
I am not sure what's wrong here! I have simply followed the document and I was hoping it should have worked fine but not. I am new to OSGi framework. I was expecting both of those classes to have @Component annotation but they have got @ProviderType annotation!
I have gone through blog to know more about ProviderType, but couldn't gather much from that too.
@Krishna: We both have hit the same roadblock, need to find a solution. I will post here if I get something, you too please do the same.
EDIT:
I just checked the inspect cap service command for guesbook-api and guestbook-service, they DO NOT return the expected services
g! inspect cap service 560
com.liferay.docs.guestbook.api_1.0.0 [560] provides:
----------------------------------------------------
service [EMPTY]
g! inspect cap service 561
com.liferay.docs.guestbook.service_1.0.0 [561] provides:
--------------------------------------------------------
service; com.liferay.portal.kernel.security.permission.ResourcePermissionChecker with properties:
resource.name = com.liferay.docs.guestbook
component.name = com.liferay.docs.guestbook.service.permission.GuestbookModelPermission
component.id = 2595
service.id = 7282
service.bundleid = 561
service.scope = bundle
Thanks
Ketan
6年前 に Richard Sezov によって更新されました。
RE: Service are not getting registered in OSGI container
Regular Member 投稿: 220 参加年月日: 07/02/07 最新の投稿
That definitely doesn't look right. I have the whole project locally (you can find it here), and this is what should be returned:
My suggestion would be to compare your project with the completed one from our repo; it's possible that either you missed a step or we failed to capture one (though we had four people go over it before publishing, so I hope not).
g! inspect cap service 519
com.liferay.docs.guestbook.service_1.0.0 [519] provides:
--------------------------------------------------------
service; com.liferay.portal.kernel.security.permission.ResourcePermissionChecker with properties:
resource.name = com.liferay.docs.guestbook
component.name = com.liferay.docs.guestbook.service.permission.GuestbookModelPermission
component.id = 34
service.id = 96
service.bundleid = 519
service.scope = bundle
service; com.liferay.portal.spring.transaction.TransactionInterceptor with properties:
origin.bundle.symbolic.name = com.liferay.docs.guestbook.service
service.id = 4334
service.bundleid = 519
service.scope = singleton
service; com.liferay.portal.kernel.monitoring.ServiceMonitoringControl, com.liferay.portal.monitoring.statistics.service.ServiceMonitorAdvice with properties:
origin.bundle.symbolic.name = com.liferay.docs.guestbook.service
service.id = 4335
service.bundleid = 519
service.scope = singleton
service; com.liferay.portal.service.ServiceContextAdvice with properties:
origin.bundle.symbolic.name = com.liferay.docs.guestbook.service
service.id = 4336
service.bundleid = 519
service.scope = singleton
service; com.liferay.portal.spring.aop.RetryAdvice with properties:
origin.bundle.symbolic.name = com.liferay.docs.guestbook.service
service.id = 4337
service.bundleid = 519
service.scope = singleton
service; com.liferay.portal.spring.aop.ServiceBeanAutoProxyCreator with properties:
origin.bundle.symbolic.name = com.liferay.docs.guestbook.service
service.id = 4338
service.bundleid = 519
service.scope = singleton
service; com.liferay.portal.spring.aop.SkipAdvice with properties:
origin.bundle.symbolic.name = com.liferay.docs.guestbook.service
service.id = 4339
service.bundleid = 519
service.scope = singleton
service; com.liferay.portal.spring.context.PortletBeanFactoryCleaner with properties:
origin.bundle.symbolic.name = com.liferay.docs.guestbook.service
service.id = 4340
service.bundleid = 519
service.scope = singleton
service; com.liferay.portal.spring.transaction.AnnotationTransactionAttributeSource with properties:
origin.bundle.symbolic.name = com.liferay.docs.guestbook.service
service.id = 4341
service.bundleid = 519
service.scope = singleton
service; com.liferay.portal.spring.transaction.TransactionHandler, com.liferay.portal.spring.transaction.TransactionExecutor, com.liferay.portal.spring.transaction.DefaultTransactionExecutor with properties:
origin.bundle.symbolic.name = com.liferay.docs.guestbook.service
service.id = 4342
service.bundleid = 519
service.scope = singleton
service; com.liferay.portal.cluster.ClusterableChainableMethodAdviceInjector with properties:
origin.bundle.symbolic.name = com.liferay.docs.guestbook.service
service.id = 4343
service.bundleid = 519
service.scope = singleton
service; com.liferay.portal.dao.orm.hibernate.VerifySessionFactoryWrapper with properties:
origin.bundle.symbolic.name = com.liferay.docs.guestbook.service
service.id = 4344
service.bundleid = 519
service.scope = singleton
service; com.liferay.portal.spring.hibernate.PortletTransactionManager with properties:
origin.bundle.symbolic.name = com.liferay.docs.guestbook.service
service.id = 4345
service.bundleid = 519
service.scope = singleton
service; javax.sql.DataSource with properties:
origin.bundle.symbolic.name = com.liferay.docs.guestbook.service
service.id = 4346
service.bundleid = 519
service.scope = singleton
service; com.liferay.portal.spring.hibernate.LastSessionRecorderHibernateTransactionManager with properties:
origin.bundle.symbolic.name = com.liferay.docs.guestbook.service
service.id = 4347
service.bundleid = 519
service.scope = singleton
service; com.liferay.portal.kernel.service.BaseLocalService, com.liferay.portal.kernel.module.framework.service.IdentifiableOSGiService, com.liferay.docs.guestbook.service.EntryLocalService with properties:
origin.bundle.symbolic.name = com.liferay.docs.guestbook.service
service.id = 4348
service.bundleid = 519
service.scope = singleton
Used by:
com.liferay.docs.guestbook.service_1.0.0 [519]
service; com.liferay.portal.kernel.security.permission.BaseModelPermissionChecker with properties:
component.name = com.liferay.docs.guestbook.service.permission.EntryPermission
component.id = 33
model.class.name = com.liferay.docs.guestbook.model.Entry
service.id = 4349
service.bundleid = 519
service.scope = bundle
Used by:
org.eclipse.osgi_3.10.200.v20150831-0856 [0]
service; com.liferay.docs.guestbook.service.EntryService with properties:
json.web.service.context.name = gb
origin.bundle.symbolic.name = com.liferay.docs.guestbook.service
json.web.service.context.path = Entry
service.id = 4350
service.bundleid = 519
service.scope = singleton
Used by:
com.liferay.portal.remote.json.web.service.extender_2.0.5 [386]
com.liferay.docs.guestbook.portlet_1.0.0 [509]
service; com.liferay.docs.guestbook.service.persistence.EntryPersistence, com.liferay.docs.guestbook.service.persistence.impl.EntryPersistenceImpl, com.liferay.portal.kernel.service.persistence.BasePersistence with properties:
origin.bundle.symbolic.name = com.liferay.docs.guestbook.service
service.id = 4351
service.bundleid = 519
service.scope = singleton
service; com.liferay.portal.kernel.service.BaseLocalService, com.liferay.portal.kernel.module.framework.service.IdentifiableOSGiService, com.liferay.docs.guestbook.service.GuestbookLocalService with properties:
origin.bundle.symbolic.name = com.liferay.docs.guestbook.service
service.id = 4352
service.bundleid = 519
service.scope = singleton
Used by:
com.liferay.docs.guestbook.service_1.0.0 [519]
service; com.liferay.portal.kernel.search.Indexer with properties:
component.name = com.liferay.docs.guestbook.search.EntryIndexer
component.id = 31
service.id = 4353
service.bundleid = 519
service.scope = bundle
Used by:
com.liferay.portal.search_3.6.6 [395]
service; com.liferay.portal.kernel.search.Indexer with properties:
component.name = com.liferay.docs.guestbook.search.GuestbookIndexer
component.id = 32
service.id = 4355
service.bundleid = 519
service.scope = bundle
Used by:
com.liferay.portal.search_3.6.6 [395]
service; com.liferay.portal.kernel.security.permission.BaseModelPermissionChecker with properties:
component.name = com.liferay.docs.guestbook.service.permission.GuestbookPermission
component.id = 35
model.class.name = com.liferay.docs.guestbook.model.Guestbook
service.id = 4357
service.bundleid = 519
service.scope = bundle
Used by:
org.eclipse.osgi_3.10.200.v20150831-0856 [0]
service; com.liferay.docs.guestbook.service.GuestbookService with properties:
json.web.service.context.name = gb
origin.bundle.symbolic.name = com.liferay.docs.guestbook.service
json.web.service.context.path = Guestbook
service.id = 4358
service.bundleid = 519
service.scope = singleton
Used by:
com.liferay.docs.guestbook.portlet_1.0.0 [509]
com.liferay.portal.remote.json.web.service.extender_2.0.5 [386]
service; com.liferay.docs.guestbook.service.persistence.GuestbookPersistence, com.liferay.docs.guestbook.service.persistence.impl.GuestbookPersistenceImpl, com.liferay.portal.kernel.service.persistence.BasePersistence with properties:
origin.bundle.symbolic.name = com.liferay.docs.guestbook.service
service.id = 4361
service.bundleid = 519
service.scope = singleton
service; org.springframework.context.ApplicationContext with properties:
org.springframework.context.service.name = com.liferay.docs.guestbook.service
service.id = 4362
service.bundleid = 519
service.scope = singleton
service; com.liferay.asset.kernel.model.AssetRendererFactory with properties:
ServletContext.target = (osgi.web.symbolicname=com.liferay.docs.guestbook.portlet)
javax.portlet.name = com_liferay_docs_guestbook_portlet_GuestbookPortlet
component.name = com.liferay.docs.guestbook.asset.EntryAssetRendererFactory
component.id = 29
service.id = 6754
service.bundleid = 519
service.scope = bundle
Used by:
org.eclipse.osgi_3.10.200.v20150831-0856 [0]
service; com.liferay.asset.kernel.model.AssetRendererFactory with properties:
ServletContext.target = (osgi.web.symbolicname=com.liferay.docs.guestbook.portlet)
javax.portlet.name = com_liferay_docs_guestbook_portlet_GuestbookPortlet
component.name = com.liferay.docs.guestbook.asset.GuestbookAssetRendererFactory
component.id = 30
service.id = 6755
service.bundleid = 519
service.scope = bundle
Used by:
org.eclipse.osgi_3.10.200.v20150831-0856 [0]
My suggestion would be to compare your project with the completed one from our repo; it's possible that either you missed a step or we failed to capture one (though we had four people go over it before publishing, so I hope not).
6年前 に Ketan Solanki によって更新されました。
RE: Service are not getting registered in OSGI container
Junior Member 投稿: 63 参加年月日: 14/05/28 最新の投稿Richard Sezov:
That definitely doesn't look right. I have the whole project locally (you can find it here)
Hi Richard,
First of all, thanks very much for sharing this link with me. Slowly I am realizing that Liferay got lots of reference resources, just need to look around at right places! And you have pointed out exactly that to me in this instance...
I deployed that source code, and I had to make following change in guesbook-api bnd.bnd file I added below in Export-Package to already existing ones:
com.liferay.docs.guestbook,\
com.liferay.docs.guestbook.search
And then the example is working like charm I am very happy now... seriously...
Comparison with Developing a web application example:
Above doc is missing out certain things as following:
Critical:
- compileOnly group: "com.liferay", name: "com.liferay.registry.api", version: "1.0.0"
in guestbook-service -> build.gradle file, I guess this is the one responsible for registering services in OSGi. Not sure though because this is compileTime only
Other notable things:
- EntryService and GuesbookService are missing methods, and hence subsequent impl and util classes
- While auto generating the code using service builder, it didn't generate exception classes for me - somehow!
- guesbook-service' build.gradle file is missing compileOnly entries of portlet-api and javax.servlet-api
I am looking for an example of search suggestion too. I tried to look for that in the example code repository that you shared, but didn't get it inside. Please let me know if there is any reference implementation available for search suggestion.
P.S. I was using latest Liferay Developer Studio for working on this example.
Once again, thanks very much for sharing this link and info, that is very helpful. May be this link can be included somewhere in the doc itself so people can easily find it!?