In OSGi CXF uses one bus per bundle. So it will not work to just use the thread default bus which is quite unsafe to use anyway.
So the correct way is to bind to all services with the Bus interface and go through all of them. The preferred way to do this is with DS or blueprint as it is quite easy to do it wrong with the plain OSGi APIs. I just looked into the CXF command source and found that retrieving the services is done incorrectly there. Christian 2016-06-30 18:12 GMT+02:00 Leandro Andrade <[email protected]>: > Hi, > > I'm implementing in Karaf 3.0.6 a bundle. In this bundle I'm trying get > info > about all CXF services registered in my Karaf. > > Using the karaf console it's simple: > $cxf:list-endpoints > > But I want do it using Java code. I implementation of cxf-commands I saw > the > method .getServers(), but it need a instance of Bus. I tired: > > Bus bus = CXFBusFactory.getThreadDefaultBus(); > ServerRegistry serverRegistry = bus.getExtension(ServerRegistry.class); > List<Server> servers = serverRegistry.getServers(); > > However I received the error: > > java.lang.IllegalAccessError: tried to access class > org.apache.cxf.BusFactory$BusHolder from class org.apache.cxf.BusFactory > at > org.apache.cxf.BusFactory.getThreadBusHolder(BusFactory.java:124) > at > org.apache.cxf.BusFactory.getThreadDefaultBus(BusFactory.java:225) > at > org.apache.cxf.BusFactory.getThreadDefaultBus(BusFactory.java:214) > at > > br.ufba.dcc.wiser.smartufba.mqttfuseki.MqttCxfController.<init>(MqttCxfController.java:40) > at > br.ufba.dcc.wiser.smartufba.mqttfuseki.Activator$1.run(Activator.java:31) > at java.lang.Thread.run(Thread.java:745) > > Somebody can help me with this? > > Thanks a lot > > Regards, > > > Leandro Andrade > > > > > > > -- > View this message in context: > http://cxf.547215.n5.nabble.com/Doubt-in-implementation-of-get-all-CXF-services-in-a-karaf-bundle-tp5769879.html > Sent from the cxf-user mailing list archive at Nabble.com. > -- -- Christian Schneider http://www.liquid-reality.de <https://owa.talend.com/owa/redir.aspx?C=3aa4083e0c744ae1ba52bd062c5a7e46&URL=http%3a%2f%2fwww.liquid-reality.de> Open Source Architect http://www.talend.com <https://owa.talend.com/owa/redir.aspx?C=3aa4083e0c744ae1ba52bd062c5a7e46&URL=http%3a%2f%2fwww.talend.com>
