Hi Isuru,

why are you loading the app context from jndi? In an OSGi environment you should either use spring dm orr blueprint for that. So you simply put your xml in either META-INF/spring or META-INF/blueprint and the respective stack picks it up.

Can you provide your whole project? Or even better a small project that also shows your problem?

Have a look at http://www.liquid-reality.de/display/liquid/2011/12/22/Karaf+Tutorial+Part+4+-+CXF+Services+in+OSGi for a small example. This example works in Karaf but should also work in plain equinox if you install all necessary bundles.

Still you should first try with Karaf as it will be easiest to get working. Then you can check which bundles karaf uses and
use the same in pure equinox.

Talend Service Factory is not available anymore as it was too similar to TESB and TIF to manage them separately. So you can use TESB but Karaf will also do fine and is much smaller. My article above describes how to setup karaf for CXF. It should be a matter of less than 10 mins to get the example working. Then you can start from this to make your project work too.

Christian


Am 01.03.2012 11:03, schrieb Isuru Suriarachchi:
Hi Christian,

I could move forward a little bit. But now I'm facing the following issue.

[2012-03-01 15:17:02,983]  INFO
{org.springframework.beans.factory.xml.XmlBeanDefinitionReader} -  Loading
XML bean definitions from URL
[jndi:/localhost/cxf-library/WEB-INF/cxf-servlet.xml]
Mar 1, 2012 3:17:05 PM org.apache.catalina.core.ApplicationContext log
SEVERE: StandardWrapper.Throwable
org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
Configuration problem: Unable to locate Spring NamespaceHandler for XML
schema namespace [http://cxf.apache.org/jaxws]
Offending resource: URL
[jndi:/localhost/cxf-library/WEB-INF/cxf-servlet.xml]
at
org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
at
org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
at
org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80)
at
org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:316)
at
org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1416)
at
org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1409)

So it looks like spring framework has not been able to
load org.apache.cxf.jaxws.spring.NamespaceHandler class or it doesn't see
the spring.handlers file. But my cxf bundle has the spring.handlers file in
META-INF and it has the org.apache.cxf.jaxws.spring.NamespaceHandler class
as well.

Do you have any idea about whats going on here?

Actually we are trying to include CXF in our existing Equinox environment.
Therefore moving to some other OSGi container is not an option for us. I
tried to download the Talend Services Factory from [1]. But looks like it's
no longer there. Do I have to download Talend ESB?

Thanks,
~Isuru

[1] http://www.talend.com/download.php

On Wed, Feb 8, 2012 at 9:38 PM, Christian Schneider<[email protected]
wrote:
CXF works very well in OSGi. Making it work together with spring is a
little harder as spring dm has very bad classloading but that also works.

First of all you should check if you can use Karaf as your container. It
also can work with equinox so it should not be a big change for you.
Karaf allows to install cxf in a very simple way and is the best way to
get cxf to work in osgi.

You can take a look at the Talend Service factory examples:
https://github.com/Talend/tsf

Basically Talend Service Factory is Karaf+Equinox+CXF. So that should be
quite nearto what you have.

The key to make spring work with cxf in OSGi is to define the correct
import or require bundle statements. For CXF<  2.6.0 there is only a single
CXF bundle so it is easiest to do
require bundle on it.

This will import among other things the META-INF/cxf package. So the
cxf.xml will be found. Btw. in current CXF versions you only need cxf.xml.
The other imports are not necessary anymore.

The best way to work with cxf in OSGi though is to use aries blueprint
instead of cxf. It has much better classloading. So when you use maven and
the bundle plugin to create your bundles you normally do not need to define
imports manually when using blueprint. This makes using OSGi almost as
simple as plain java.

I wrote a Tutorial for CXF on Karaf with blueprint some time ago:
http://www.liquid-reality.de/**display/liquid/2011/12/22/**
Karaf+Tutorial+Part+4+-+CXF+**Services+in+OSGi<http://www.liquid-reality.de/display/liquid/2011/12/22/Karaf+Tutorial+Part+4+-+CXF+Services+in+OSGi>

The examples are on github and are really simple:
https://github.com/cschneider/**Karaf-Tutorial/tree/master/**
cxf/personservice<https://github.com/cschneider/Karaf-Tutorial/tree/master/cxf/personservice>

Christian


Am 08.02.2012 15:45, schrieb Isuru Suriarachchi:

  Hi all,
I'm trying to bring CXF into my OSGi container (equinox). So the spring
framework is a single bundle and cxf is a separate bundle. And my web.xml
has the following context param.

<context-param>
     <param-name>**contextConfigLocation</param-**name>
     <param-value>
       classpath:META-INF/cxf/cxf.xml
       classpath:META-INF/cxf/cxf-**extension-soap.xml
       classpath:META-INF/cxf/cxf-**servlet.xml
      </param-value>
   </context-param>

But when I try to deploy this, I get the following exception.

SEVERE: Exception sending context initialized event to listener instance
of
class org.springframework.web.**context.ContextLoaderListener
org.springframework.beans.**factory.**BeanDefinitionStoreException:
IOException
parsing XML document from class path resource [META-INF/cxf/cxf.xml];
nested exception is java.io.FileNotFoundException: class path resource
[META-INF/cxf/cxf.xml] cannot be opened because it does not exist
         at
org.springframework.beans.**factory.xml.**XmlBeanDefinitionReader.**
loadBeanDefinitions(**XmlBeanDefinitionReader.java:**341)
         at
org.springframework.beans.**factory.xml.**XmlBeanDefinitionReader.**
loadBeanDefinitions(**XmlBeanDefinitionReader.java:**302)
         at
org.springframework.beans.**factory.support.**
AbstractBeanDefinitionReader.**loadBeanDefinitions(**
AbstractBeanDefinitionReader.**java:143)
         at
org.springframework.beans.**factory.support.**
AbstractBeanDefinitionReader.**loadBeanDefinitions(**
AbstractBeanDefinitionReader.**java:178)

So it looks like the spring framework can't see the cxf.xml which is in
the
CXF bundle. Is there a way to overcome this issue? Have anyone tried to
use
CXF within OSGi?

Thanks,
~Isuru


--
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
Talend Application Integration Division http://www.talend.com




--

Christian Schneider
http://www.liquid-reality.de

Open Source Architect
Talend Application Integration Division http://www.talend.com

Reply via email to