I am attempting to use CXF within OSGi enRoute (http://enroute.osgi.org/), but 
having some issues.

First, my objectives:
No cfx.xml file, but instead to bootstrap all attributes normally found in a 
cxf.xml file from OSGi configurations
Understand if I should have one bus for all bundles exposing SOAP services, or 
one bus per bundle.  
Have each bundle use JaxWsServerFactoryBean to register its services within the 
bundle activator during startup, and unregister these services when the bundle 
is stopping

I am getting errors when running just a single bundle with no cxf.xml files and 
no registered services.  Details below.

———————————

I have a single application bundle which does nothing more than call the 
following on bundle activation:

public class Activator implements BundleActivator
{
        @Override
        public void start(BundleContext context) throws Exception
        {
                try {
                        System.out.println("activating application - start");
                        BusFactory.getDefaultBus();
                        System.out.println("activating application - end");
                } catch (Throwable e) {
                        e.printStackTrace();
                }
        }


        @Override
        public void stop(BundleContext context) throws Exception
        {
                // forthcoming
        }
}


The output I get from this is as follows:

activating application - start
Aug 25, 2016 11:43:37 PM org.apache.cxf.bus.osgi.CXFExtensionBundleListener 
addExtensions
INFO: Adding the extensions from bundle org.apache.cxf.cxf-rt-bindings-xml (3) 
[org.apache.cxf.binding.xml.XMLBindingFactory, 
org.apache.cxf.binding.xml.wsdl11.XMLWSDLExtensionLoader]
Aug 25, 2016 11:43:37 PM org.apache.cxf.bus.osgi.CXFExtensionBundleListener 
addExtensions
INFO: Adding the extensions from bundle org.apache.cxf.cxf-rt-transports-http 
(5) [org.apache.cxf.transport.http.HTTPTransportFactory, 
org.apache.cxf.transport.http.HTTPWSDLExtensionLoader, 
org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder, 
org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder, 
org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider]
Aug 25, 2016 11:43:37 PM org.apache.cxf.bus.osgi.CXFExtensionBundleListener 
addExtensions
INFO: Adding the extensions from bundle 
org.apache.cxf.cxf-rt-transports-http-jetty (6) 
[org.apache.cxf.transport.http_jetty.JettyDestinationFactory, 
org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory, 
org.apache.cxf.transport.http.ContinuationProviderFactory]
Aug 25, 2016 11:43:37 PM 
org.apache.cxf.bus.blueprint.NamespaceHandlerRegisterer register
WARNING: Aries Blueprint packages not available. So namespaces will not be 
registered
Aug 25, 2016 11:43:37 PM 
org.apache.cxf.bus.blueprint.NamespaceHandlerRegisterer register
WARNING: Aries Blueprint packages not available. So namespaces will not be 
registered
Aug 25, 2016 11:43:37 PM 
org.apache.cxf.bus.blueprint.NamespaceHandlerRegisterer register
WARNING: Aries Blueprint packages not available. So namespaces will not be 
registered
activating application - end
2016-08-25 23:43:38.022:INFO::main: Logging initialized @1270ms
2016-08-25 23:43:38.052:INFO:oejs.Server:main: jetty-9.2.12.v20150709
2016-08-25 23:43:38.104:INFO:oejsh.ContextHandler:main: Started 
o.e.j.s.ServletContextHandler@19d481b{/,null,AVAILABLE}
2016-08-25 23:43:38.104:INFO:oejs.Server:main: Started @1351ms
2016-08-25 23:43:38.124:INFO:oejs.ServerConnector:main: Started 
ServerConnector@4738a206{HTTP/1.1}{0.0.0.0:8080}
[INFO] Started Jetty 9.2.12.v20150709 at port(s) HTTP:8080 on context path /
Aug 25, 2016 11:43:38 PM org.apache.cxf.transport.http.osgi.ServletExporter 
updated
WARNING: Error registering CXF OSGi servlet Alias /cxf is already in use.
org.osgi.service.http.NamespaceException: Alias /cxf is already in use.
        at 
org.apache.felix.http.base.internal.service.SharedHttpServiceImpl.registerServlet(SharedHttpServiceImpl.java:74)
        at 
org.apache.felix.http.base.internal.service.PerBundleHttpServiceImpl.registerServlet(PerBundleHttpServiceImpl.java:217)
        at 
org.apache.cxf.transport.http.osgi.ServletExporter.updated(ServletExporter.java:108)
        at 
org.apache.felix.cm.impl.helper.ManagedServiceTracker.updated(ManagedServiceTracker.java:189)
        at 
org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(ManagedServiceTracker.java:152)
        at 
org.apache.felix.cm.impl.helper.ManagedServiceTracker.provideConfiguration(ManagedServiceTracker.java:85)
        at 
org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.provide(ConfigurationManager.java:1444)
        at 
org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.run(ConfigurationManager.java:1400)
        at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:103)
        at java.lang.Thread.run(Thread.java:745)


———————————

Two comments:
Only after the bundle is activated, I get the stack trace given above 
indicating a second cxf bus has been created
I do not get errors if I do not call BusFactory.getDefaultBus() from within the 
bundle activation method

Questions:
What can I do to prevent the apparent second bus from being created?
Is it best to have one bus per bundle, each with a different servlet alias… or 
one bus for multiple bundles, all sharing a common servlet alias


Randy Leonard
[email protected]
[email protected]

Reply via email to