Can't lookup OSGI services through JNDI

会有一股神秘感。 提交于 2019-12-07 16:59:00

问题


I'm working with JBossAS7. My application has some OSGI modules and big non-OSGI part. I tried lookup osgi services in non-osgi subsystem through JNDI but they are not present in JNDI context. I found similar problem at JBOSS 7 - Osgi Bundles not present in JNDI TREE but I dont found any solution there. If JBoss team didn't implement this functionality yet, how can I resolve this problem now?

I tried adding my service to JNDI context manually but got an exception because JNDI context is read only(according to https://issues.jboss.org/browse/AS7-421)


回答1:


It's not fully integrated yet (monitor JBOSGI-81 to check the status), however I think you can make this work by taking the Apache Aries JNDI OSGi bundles and deploying them in JBoss AS7.

To do this, deploy and start

  • The Aries JNDI bundle
  • The Aries Proxy bundle
  • The Aries Util bundle

The JNDI bundle will complain that it can't set some statics with the NamingManager, but you can ignore that as AS7 JNDI takes care of that. With the bundles above installed you should be able to do

osgi:service/org.foo.SomeInterface

and

osgi:servicelist 

type lookups... E.g. you could try the following to look up the Start Level Service which is registered by the framework:

osgi:service/org.osgi.service.startlevel.StartLevel

I just tried it with AS7 7.1.2 and it works for me...

One thing to note, if the entity you're looking up implements an interface defined in another AS7/MSC module or OSGi bundle, you need to ensure that the consumer has visibility to it if you want to be able to cast to this interface. In the OSGi world you can just import the package, but in an AS7 module (e.g. a war file) you can achieve this by adding a Dependencies manifest header.



来源:https://stackoverflow.com/questions/10483740/cant-lookup-osgi-services-through-jndi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!