-1

I have a set of bundles deployed in Karaf and exposing a number of OSGi services which I would like to be able to lookup and call remotely, from an application running on a (possibly) different machine and in a non-OSGi container. My initial though was to use JNDI lookup to get the services I want however I understand from an earlier stackoverflow post that this might not be supported (I say might since I haven't been able to find any information on whether anything has changed on the Aries JNDI implementation in the past year). In that case I guess my other options would be to use CXF to expose a JAX-WS or JAX-RS API for my services.

Is my understanding of the situation correct? Is JNDI lookup really not an option in my case? Are there any other alternatives I have not thought of?

Community
  • 1
  • 1
Christina
  • 3,562
  • 3
  • 22
  • 32

2 Answers2

1

A simple jndi lookup will not work. OSGi services are not suitable for remoting per se. So even if you can get the jndi object in some way you can not call it.

Possible solutions are manual cxf proxies and endpoints like you already found and Distributed OSGi. See CXF-DOSGi and Eclipse ECF. Both can offer transaparent service calls from one OSGi framework to another. DOSGi is ideal if you also use OSGi on the client side. At least in case of CXF DOSGi it is also possible to use DOSGi on the server side and a normal CXF client on the client side. So you can keep the effort on the server side minimal.

See also this tutorial for CXF DOSGi

Christian Schneider
  • 19,420
  • 2
  • 39
  • 64
  • Thank you Christian. What is a bit unclear to me is how I can connect to DOSGi from a non-OSGi client. Do you have any references/examples that could help me with that? – Christina Jun 24 '14 at 10:12
  • Just export a service in the usual DOSGi way and check the cxf servlet on http://localhost:8181/cxf. You should see the service URI there. – Christian Schneider Jun 24 '14 at 12:34
  • I've published a sample service to DOSGi as you suggest, and indeed it seems like the way to go, however I'm so far not able to understand why I can only access the published endpoint from localhost (event from the machine where the endpoint is deployed I can access it on http://localhost:9090/hello?wsdl but not on http://:9090/hello?wsdl). Is there a configuration I'm missing? – Christina Jun 25 '14 at 13:15
  • How did you specify the export? If you specify the full uri as http://localhost:9090/hello then indeed it works only on localhost. Try to use a path like /hello or specify your hostname in the uri. I always use the /hello variant which uses the OSGi HTTPService so all services share the same servlet. – Christian Schneider Jun 25 '14 at 19:19
  • That was indeed the problem. I was trying with just /hello but in the org.apache.cxf.ws.httpservice.context instead of org.apache.cxf.ws.address. Thank you for your help. – Christina Jun 26 '14 at 05:53
1

You need a Remote Services implementation. See https://en.wikipedia.org/w/index.php?title=OSGi_Specification_Implementations for a list.

BJ Hargrave
  • 9,324
  • 1
  • 19
  • 27