Dave,
Guillaume Nodet definitely has more experience with the OSGi stuff. In
generaly, we've seen success using the Spring Dynamic Module stuff with
OSGi as you can import the cxf stuff you need in the spring module and
the bus gets wired up correctly. (in 2.0.6/2.1, we even added a
cxf-all.xml that you can import to grab everything, but thats probably
more than you need)
I'm not sure if anyone not using spring-dm has gotten anything to work.
One option MAY be to call SpringBusFactory.createBus() yourself first to
cause the Bus to be created with spring. Not sure if that works though
as I'm not sure if it will find all the spring config files or not.
Dan
On Tuesday 29 April 2008, Dave Brosius wrote:
> OK, this code is failing in OSGI
>
> BusFactory.getBusFactoryClass
>
> specifically, it tries to load the file
>
> META-INF/services/org.apache.cxf.bus.factory
>
> and fails.
>
> [CODE]
> private static String getBusFactoryClass(ClassLoader classLoader) {
>
> String busFactoryClass = null;
> String busFactoryCondition = null;
>
> // next check system properties
> busFactoryClass =
> System.getProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME); if
> (isValidBusFactoryClass(busFactoryClass)) {
> return busFactoryClass;
> }
>
> try {
> // next, check for the services stuff in the jar file
> String serviceId = "META-INF/services/" +
> BusFactory.BUS_FACTORY_PROPERTY_NAME; InputStream is = null;
>
> if (classLoader == null) {
> classLoader =
> Thread.currentThread().getContextClassLoader(); }
>
> if (classLoader == null) {
> is = ClassLoader.getSystemResourceAsStream(serviceId);
> } else {
> is = classLoader.getResourceAsStream(serviceId);
> }
> if (is != null) {
> BufferedReader rd = new BufferedReader(new
> InputStreamReader(is, "UTF-8")); busFactoryClass = rd.readLine();
> busFactoryCondition = rd.readLine();
> rd.close();
> }
> if (isValidBusFactoryClass(busFactoryClass)) {
> if (busFactoryCondition != null) {
> try {
> classLoader.loadClass(busFactoryCondition);
> return busFactoryClass;
> } catch (ClassNotFoundException e) {
> return DEFAULT_BUS_FACTORY;
> }
> } else {
> return busFactoryClass;
> }
> }
>
> // otherwise use default
> busFactoryClass = BusFactory.DEFAULT_BUS_FACTORY;
> return busFactoryClass;
> } catch (Exception ex) {
> LogUtils.log(LOG, Level.SEVERE,
> "FAILED_TO_DETERMINE_BUS_FACTORY_EXC", ex); }
> return busFactoryClass;
> }
> [/CODE]
>
>
> -----Original Message-----
> From: Dave Brosius <[EMAIL PROTECTED]>
> Sent: Tuesday, April 29, 2008 6:27pm
> To: [email protected]
> Cc: [EMAIL PROTECTED]
> Subject: RE: cxf Autowiring in OSGI
>
> Here's the difference: Can anyone help me with why this is so?
>
> In OSGI, createBus creates a CXFBusFactory
>
> Thread [SpringOsgiExtenderThread-2] (Suspended)
> CXFBusFactory.createBus() line: 32
> BusFactory.getDefaultBus(boolean) line: 69
> BusFactory.getThreadDefaultBus(boolean) line: 106
> BusFactory.getThreadDefaultBus() line: 97
> JaxWsServerFactoryBean(AbstractEndpointFactory).getBus() line: 73
> JaxWsServerFactoryBean(AbstractWSDLBasedEndpointFactory).initializeSe
>rviceFactory() line: 143
> JaxWsServerFactoryBean(AbstractWSDLBasedEndpointFactory).createEndpoin
>t() line: 73 JaxWsServerFactoryBean(ServerFactoryBean).create() line:
> 113 JaxWsServerFactoryBean.create() line: 160
> EchoInstaller.init() line: 23
> NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not
> available [native method] NativeMethodAccessorImpl.invoke(Object,
> Object[]) line: 39
> DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
> Method.invoke(Object, Object...) line: 585
> DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).invoke
>CustomInitMethod(String, Object, String, boolean) line: 1378
> DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).invokeI
>nitMethods(String, Object, RootBeanDefinition) line: 1339
> DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).initial
>izeBean(String, Object, RootBeanDefinition) line: 1299
> DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).doCreat
>eBean(String, RootBeanDefinition, Object[]) line: 463
> AbstractAutowireCapableBeanFactory$1.run() line: 404
> AccessController.doPrivileged(PrivilegedAction<T>) line: not
> available [native method]
> DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).createB
>ean(String, RootBeanDefinition, Object[]) line: 375
> AbstractBeanFactory$1.getObject() line: 263
> DefaultListableBeanFactory(DefaultSingletonBeanRegistry).getSingleton
>(String, ObjectFactory) line: 170
> DefaultListableBeanFactory(AbstractBeanFactory).doGetBean(String,
> Class, Object[], boolean) line: 260
> DefaultListableBeanFactory(AbstractBeanFactory).getBean(String, Class,
> Object[]) line: 184
> DefaultListableBeanFactory(AbstractBeanFactory).getBean(String) line:
> 163 DefaultListableBeanFactory.preInstantiateSingletons() line: 430
> OsgiBundleXmlApplicationContext(AbstractApplicationContext).finishBean
>FactoryInitialization(ConfigurableListableBeanFactory) line: 729
> OsgiBundleXmlApplicationContext(AbstractDelegatedExecutionApplicationC
>ontext).completeRefresh() line: 268
> DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run()
> line: 142
> DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run()
> line: 142 Thread.run() line: 595
>
>
> In standard mode, createBus creates a SpringBusFactory
>
> Thread [main] (Suspended (breakpoint at line 54 in SpringBusFactory))
> SpringBusFactory.createBus() line: 54
> BusFactory.getDefaultBus(boolean) line: 69
> BusFactory.getThreadDefaultBus(boolean) line: 106
> BusFactory.getThreadDefaultBus() line: 97
> JaxWsServerFactoryBean(AbstractEndpointFactory).getBus() line: 73
> JaxWsServerFactoryBean(AbstractWSDLBasedEndpointFactory).initializeSe
>rviceFactory() line: 143
> JaxWsServerFactoryBean(ServerFactoryBean).initializeServiceFactory()
> line: 149
> JaxWsServerFactoryBean(AbstractWSDLBasedEndpointFactory).createEndpoin
>t() line: 73 JaxWsServerFactoryBean(ServerFactoryBean).create() line:
> 113 JaxWsServerFactoryBean.create() line: 160
> Main.main(String[]) line: 19
>
>
>
>
> -----Original Message-----
> From: Dave Brosius <[EMAIL PROTECTED]>
> Sent: Tuesday, April 29, 2008 6:15pm
> To: [email protected]
> Cc: [EMAIL PROTECTED]
> Subject: cxf Autowiring in OSGI
>
> I am having trouble getting cxf to work in osgi. The problem is that
> it appears that there are no factories registered for the various
> namespaces needed such as http://schemas.xmlsoap.org/soap/http
>
>
> When run in normal mode (not osgi), I see these namespaces being
> registered (in the below stack trace). In OSGI this isn't happening
> and so it fails in JaxWsServerFactoryBean.createBindingInfo. Does
> anyone have any ideas about how to fix this?
>
>
> [CODE]
> Thread [main] (Suspended (breakpoint at line 79 in
> DestinationFactoryManagerImpl))
> DestinationFactoryManagerImpl.registerDestinationFactory(String,
> DestinationFactory) line: 79
> JettyHTTPTransportFactory.finalizeConfig() line: 68
> NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not
> available [native method] NativeMethodAccessorImpl.invoke(Object,
> Object[]) line: 39
> DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
> Method.invoke(Object, Object...) line: 585
> ResourceInjector.invokePostConstruct() line: 305
> ResourceInjector.construct(Object) line: 86
> Jsr250BeanPostProcessor.postProcessAfterInitialization(Object,
> String) line: 58
> DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).applyBe
>anPostProcessorsAfterInitialization(Object, String) line: 357
> DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).initial
>izeBean(String, Object, RootBeanDefinition) line: 1308
> DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).doCreat
>eBean(String, RootBeanDefinition, Object[]) line: 463
> AbstractAutowireCapableBeanFactory$1.run() line: 404
> AccessController.doPrivileged(PrivilegedAction<T>) line: not
> available [native method]
> DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).createB
>ean(String, RootBeanDefinition, Object[]) line: 375
> AbstractBeanFactory$1.getObject() line: 263
> DefaultListableBeanFactory(DefaultSingletonBeanRegistry).getSingleton
>(String, ObjectFactory) line: 170
> DefaultListableBeanFactory(AbstractBeanFactory).doGetBean(String,
> Class, Object[], boolean) line: 260
> DefaultListableBeanFactory(AbstractBeanFactory).getBean(String, Class,
> Object[]) line: 184
> DefaultListableBeanFactory(AbstractBeanFactory).getBean(String) line:
> 163 DefaultListableBeanFactory.preInstantiateSingletons() line: 430
> BusApplicationContext(AbstractApplicationContext).finishBeanFactoryIni
>tialization(ConfigurableListableBeanFactory) line: 729
> BusApplicationContext(AbstractApplicationContext).refresh() line: 381
> BusApplicationContext.<init>(String[], boolean, ApplicationContext)
> line: 86 SpringBusFactory.createBus(String[], boolean) line: 93
> SpringBusFactory.createBus(String, boolean) line: 87
> SpringBusFactory.createBus(String) line: 65
> SpringBusFactory.createBus() line: 54
> BusFactory.getDefaultBus(boolean) line: 69
> BusFactory.getThreadDefaultBus(boolean) line: 106
> BusFactory.getThreadDefaultBus() line: 97
> JaxWsServerFactoryBean(AbstractEndpointFactory).getBus() line: 73
> JaxWsServerFactoryBean(AbstractWSDLBasedEndpointFactory).initializeSe
>rviceFactory() line: 143
> JaxWsServerFactoryBean(ServerFactoryBean).initializeServiceFactory()
> line: 149
> JaxWsServerFactoryBean(AbstractWSDLBasedEndpointFactory).createEndpoin
>t() line: 73 JaxWsServerFactoryBean(ServerFactoryBean).create() line:
> 113 JaxWsServerFactoryBean.create() line: 160
> Main.main(String[]) line: 19
> [/CODE]
--
J. Daniel Kulp
Principal Engineer, IONA
[EMAIL PROTECTED]
http://www.dankulp.com/blog