You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Christian Schneider <ch...@die-schneider.net> on 2009/11/26 17:22:22 UTC
Using CXF in Eclipse RCP
Hi all,
I am trying to call web services from an Eclipse RCP application. Is
there a howto about this?
I tried to simply install the cxf-bundle-2.2.5.jar into the eclipse
plugins directory but it did not even show up in the plugins of my
eclipse installation or target plattform. So I guess it is not that
simple ;-)
Do you have any hints for further reading?
Greetings
Christian
--
Christian Schneider
---
http://www.liquid-reality.de
Re: Using CXF in Eclipse RCP
Posted by Oisin Hurley <oi...@gmail.com>.
> Do you mean with osi-ified that someone added the manifest and possibly
> other stuff? I do not really like this practice. It means that every new
> version has to be "bundled" again.
It totally depends on the agency that is turning the plain old jar
into a bundle.
> I think the best but slowest way is to get the original projects to make
> their deployments to central osgi ready.
+1
> So what I would prefer is some kind of proxy for maven that reads from the
> normal repos and add the osgi specifics on the fly by using an additional
> database or repo. This proxy could even fail your build if a dependency can
> not be made osgi ready. This way your poms would be clean and you could
> still build fresh from an empty local repository.
That's a neat idea - but it probably would be better just to have all
jars be OSGi jars, since you can use an OSGi jar as a normal jar,
the only additions are in the manifest, which is usually not that much
overhead.
--oh
Re: Using CXF in Eclipse RCP
Posted by Christian Schneider <ch...@die-schneider.net>.
Oisin Hurley schrieb:
>> I guess the main problem is that the cxf jars define many
>> dependencies that are not osgi enabled.
>>
>
> The good news is that more and more jars are being OSGi-ified and
> fed into various bundle repositories (what we need is an aggregator
> search engine that can index and find them all!)
>
Do you mean with osi-ified that someone added the manifest and possibly
other stuff? I do not really like this practice. It means that every new
version has to be "bundled" again.
For non osgi jars the maven central repo really is the way to go. So I
wonder if this would be possible for osgi bundles too. Some projects
like cxf already make their jars osgi ready. So the problems are only
those dependencies that are not yet ready.
I think the best but slowest way is to get the original projects to make
their deployments to central osgi ready.
What I do not like is the way springsource re packages the jars. As they
add a prefix to the group id you have to adapt your poms. This will then
be problematic when you a project issues osgi ready jars. As then you
could have the springsource groupid and the normal group id in your
dependencies. This really smells like problems.
So what I would prefer is some kind of proxy for maven that reads from
the normal repos and add the osgi specifics on the fly by using an
additional database or repo. This proxy could even fail your build if a
dependency can not be made osgi ready. This way your poms would be clean
and you could still build fresh from an empty local repository.
>> So if I understand this correctly I
>> have to configure all dependencies by hand and exclude all the current
>> non-osgi dependencies. Though I understand that changing this situation is
>> not really easy
>>
>
> Not necessarily - lots of people embed 'normal' jars within an Eclipse
> bundle, it's a matter of just adding Bundle-Classpath to the MANIFEST
> and parcelling the jars in the bundle itself. So you can start and get
> things working by embedding all the jars, and once you have that level
> of satisfaction, you can refactor to use external bundles and Import-Package.
>
> Check out an example here: http://www.aqute.biz/Snippets/BundleClassPath
> and more details here: http://www.aqute.biz/Blog/2007-02-19
>
>
>> As I had no success till now I will try to simply embed the non osgi cxf in
>> a service client bundle and re export my service as an osgi service. So at
>> least my GUI project will not have to embed all the non osgi jars. This
>> solution is far from optimal but I think easier to acomplish than the above.
>>
>
> I'll second Sergey's suggestion to look at the DOSGi RI multi-bundle
> distro - I think it will help you find all of the client pieces you need.
>
> --oh
>
>
I think I will start with the dosgi distro and fall back to embedding if
this does not work.
Greetings and thanks for the help
Christian
--
Christian Schneider
---
http://www.liquid-reality.de
Re: Using CXF in Eclipse RCP
Posted by Oisin Hurley <oi...@gmail.com>.
> I guess the main problem is that the cxf jars define many
> dependencies that are not osgi enabled.
The good news is that more and more jars are being OSGi-ified and
fed into various bundle repositories (what we need is an aggregator
search engine that can index and find them all!)
> So if I understand this correctly I
> have to configure all dependencies by hand and exclude all the current
> non-osgi dependencies. Though I understand that changing this situation is
> not really easy
Not necessarily - lots of people embed 'normal' jars within an Eclipse
bundle, it's a matter of just adding Bundle-Classpath to the MANIFEST
and parcelling the jars in the bundle itself. So you can start and get
things working by embedding all the jars, and once you have that level
of satisfaction, you can refactor to use external bundles and Import-Package.
Check out an example here: http://www.aqute.biz/Snippets/BundleClassPath
and more details here: http://www.aqute.biz/Blog/2007-02-19
> As I had no success till now I will try to simply embed the non osgi cxf in
> a service client bundle and re export my service as an osgi service. So at
> least my GUI project will not have to embed all the non osgi jars. This
> solution is far from optimal but I think easier to acomplish than the above.
I'll second Sergey's suggestion to look at the DOSGi RI multi-bundle
distro - I think it will help you find all of the client pieces you need.
--oh
Re: Using CXF in Eclipse RCP
Posted by Christian Schneider <ch...@die-schneider.net>.
It seems I had not included cxf-bundle-minimal-2.2.4 in the
Require-Bundle. The problem is now that as soon as I try to add it the
project does not compile anymore as eclipse empties the
Plugin-Dependencies. I found that this always happens when some
constrained is not met. The problem is I have no idea what is going
wrong. I have copied all the plugins from dosgi into the plugins folder.
I also had an interesting problem with spring. In my eclipse there was a
version 2.5.6A of the spring jars before I copied the plugins from
dosgi. Can this have to do with the problem?
Greetings
Christian
Here is my Manifest in case that helps:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: CustomerDB
Bundle-SymbolicName: CustomerDB; singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: customerdb.Activator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.core.databinding,
org.eclipse.core.databinding.beans,
org.eclipse.core.databinding.observable,
org.eclipse.core.databinding.property,
org.eclipse.jface.databinding,
com.ibm.icu,
org.springframework.core;bundle-version="2.5.6",
org.springframework.context;bundle-version="2.5.6",
org.springframework.osgi.core;bundle-version="1.2.0",
org.springframework.osgi.extender;bundle-version="1.2.0",
org.springframework.osgi.io;bundle-version="1.2.0",
org.springframework.beans;bundle-version="2.5.6",
org.apache.cxf.bundle-minimal;bundle-version="2.2.4"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: com.example.customerservice;
uses:="javax.xml.bind,
javax.xml.ws,
javax.xml.namespace,
javax.xml.datatype",
customerdb,
customerdb.model
Bundle-ClassPath: .,
target/classes/,
src/main/resources/
Christian Schneider schrieb:
> I partially got cxf working in Eclipse RCP. I used the bundles from
> the dosgi distribution and defined the necessary ones as required
> bundles.
> My project compiles all right.
>
> In the Activator class I got thecod below. When starting the App the
> client-applicationContext.xml is loaded but then it can´t find the
> cxf.xml. I guess the resource is not visible. Any idea how I make it
> available?
>
> Greetings
>
> Christian
>
>
> public void start(BundleContext context) throws Exception {
> super.start(context);
> plugin = this;
> OsgiBundleXmlApplicationContext ccontext = new
> OsgiBundleXmlApplicationContext(
> new String[] {
> "classpath:client-applicationContext.xml" });
> ccontext.setBundleContext(context);
> ccontext.refresh();
> CustomerService client = (CustomerService)
> ccontext.getBean("customerService");
> List<Customer> resp = client.getCustomersByName("name");
> }
>
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:context="http://www.springframework.org/schema/context"
> xmlns:jaxws="http://cxf.apache.org/jaxws"
> xmlns:customer="http://customerservice.example.com/"
> xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
> http://www.springframework.org/schema/context
> http://www.springframework.org/schema/context/spring-context-2.5.xsd
> http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
> http://cxf.apache.org/jaxws
> http://cxf.apache.org/schemas/jaxws.xsd
> ">
>
> <import resource="classpath:META-INF/cxf/cxf.xml" />
> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
> <import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
>
> <jaxws:client id="customerService"
> serviceName="customer:CustomerServiceService"
> endpointName="customer:CustomerServiceEndpoint"
> address="http://localhost:9090/CustomerServicePort"
> serviceClass="com.example.customerservice.CustomerService">
> </jaxws:client>
>
> </beans>
>
>
> Sergey Beryozkin schrieb:
>> Hi
>>
>> You might want to have a look at the DOSGi RI multi-bundle
>> distribution...
>> Probably the only two bundles included in that distruibution which
>> CXF does not depend upon are CXF DSW (DOSGi distribution software
>> component) plus a Zoo-Keeper based Discovery bundle. All other
>> bundles are osgi-fied jars which are needed to resolve CXF
>> bundle dependencies. Not sure if it can help, but may be you can just
>> use those bundles in your project ...
>>
>> cheers, Sergey
>>
>>> Thanks already for the many pointers. This seems quite time
>>> consuming though. I guess the main problem is that the cxf jars
>>> define many dependencies that are not osgi enabled. So if I
>>> understand this correctly I have to configure all dependencies by
>>> hand and exclude all the current non-osgi dependencies. Though I
>>> understand that changing this situation is not really easy.
>>>
>>> As I had no success till now I will try to simply embed the non osgi
>>> cxf in a service client bundle and re export my service as an osgi
>>> service. So at least my GUI project will not have to embed all the
>>> non osgi jars. This solution is far from optimal but I think easier
>>> to acomplish than the above.
>>>
>>> Greetings
>>>
>>> Christian
>>>
>>>
>>> --
>>>
>>> Christian Schneider
>>> ---
>>> http://www.liquid-reality.de
>>>
>>
>>
>
>
--
Christian Schneider
---
http://www.liquid-reality.de
Re: Using CXF in Eclipse RCP
Posted by Christian Schneider <ch...@die-schneider.net>.
I partially got cxf working in Eclipse RCP. I used the bundles from the
dosgi distribution and defined the necessary ones as required bundles.
My project compiles all right.
In the Activator class I got thecod below. When starting the App the
client-applicationContext.xml is loaded but then it can´t find the
cxf.xml. I guess the resource is not visible. Any idea how I make it
available?
Greetings
Christian
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
OsgiBundleXmlApplicationContext ccontext = new
OsgiBundleXmlApplicationContext(
new String[] {
"classpath:client-applicationContext.xml" });
ccontext.setBundleContext(context);
ccontext.refresh();
CustomerService client = (CustomerService)
ccontext.getBean("customerService");
List<Customer> resp = client.getCustomersByName("name");
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:customer="http://customerservice.example.com/"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
<jaxws:client id="customerService"
serviceName="customer:CustomerServiceService"
endpointName="customer:CustomerServiceEndpoint"
address="http://localhost:9090/CustomerServicePort"
serviceClass="com.example.customerservice.CustomerService">
</jaxws:client>
</beans>
Sergey Beryozkin schrieb:
> Hi
>
> You might want to have a look at the DOSGi RI multi-bundle
> distribution...
> Probably the only two bundles included in that distruibution which
> CXF does not depend upon are CXF DSW (DOSGi distribution software
> component) plus a Zoo-Keeper based Discovery bundle. All other bundles
> are osgi-fied jars which are needed to resolve CXF
> bundle dependencies. Not sure if it can help, but may be you can just
> use those bundles in your project ...
>
> cheers, Sergey
>
>> Thanks already for the many pointers. This seems quite time consuming
>> though. I guess the main problem is that the cxf jars define many
>> dependencies that are not osgi enabled. So if I understand this
>> correctly I have to configure all dependencies by hand and exclude
>> all the current non-osgi dependencies. Though I understand that
>> changing this situation is not really easy.
>>
>> As I had no success till now I will try to simply embed the non osgi
>> cxf in a service client bundle and re export my service as an osgi
>> service. So at least my GUI project will not have to embed all the
>> non osgi jars. This solution is far from optimal but I think easier
>> to acomplish than the above.
>>
>> Greetings
>>
>> Christian
>>
>>
>> --
>>
>> Christian Schneider
>> ---
>> http://www.liquid-reality.de
>>
>
>
--
Christian Schneider
---
http://www.liquid-reality.de
Re: Using CXF in Eclipse RCP
Posted by Christian Schneider <ch...@die-schneider.net>.
Hi Sergey,
the dosgi distribution looks quite promising as it should include all
bundles needed for cxf-minimal. I guess I can figure out the remaining
dependencies. In my first test I want a soap / http webservice. In
production it will be soap/jms.
I just looked into the cxf minimal pom that creates the bundle. It seems
the http and jms transports are already included. So this could even be
all I need.
Greetings and many thanks
Christian
Sergey Beryozkin schrieb:
> Hi
>
> You might want to have a look at the DOSGi RI multi-bundle
> distribution...
> Probably the only two bundles included in that distruibution which
> CXF does not depend upon are CXF DSW (DOSGi distribution software
> component) plus a Zoo-Keeper based Discovery bundle. All other bundles
> are osgi-fied jars which are needed to resolve CXF
> bundle dependencies. Not sure if it can help, but may be you can just
> use those bundles in your project ...
>
> cheers, Sergey
>
>> Thanks already for the many pointers. This seems quite time consuming
>> though. I guess the main problem is that the cxf jars define many
>> dependencies that are not osgi enabled. So if I understand this
>> correctly I have to configure all dependencies by hand and exclude
>> all the current non-osgi dependencies. Though I understand that
>> changing this situation is not really easy.
>>
>> As I had no success till now I will try to simply embed the non osgi
>> cxf in a service client bundle and re export my service as an osgi
>> service. So at least my GUI project will not have to embed all the
>> non osgi jars. This solution is far from optimal but I think easier
>> to acomplish than the above.
>>
>> Greetings
>>
>> Christian
>>
>>
>> --
>>
>> Christian Schneider
>> ---
>> http://www.liquid-reality.de
>>
>
>
--
Christian Schneider
---
http://www.liquid-reality.de
Re: Using CXF in Eclipse RCP
Posted by Sergey Beryozkin <sb...@progress.com>.
Hi
You might want to have a look at the DOSGi RI multi-bundle distribution...
Probably the only two bundles included in that distruibution which CXF does not depend upon are CXF DSW (DOSGi distribution
software component) plus a Zoo-Keeper based Discovery bundle. All other bundles are osgi-fied jars which are needed to resolve CXF
bundle dependencies. Not sure if it can help, but may be you can just use those bundles in your project ...
cheers, Sergey
> Thanks already for the many pointers. This seems quite time consuming though. I guess the main problem is that the cxf jars define
> many dependencies that are not osgi enabled. So if I understand this correctly I have to configure all dependencies by hand and
> exclude all the current non-osgi dependencies. Though I understand that changing this situation is not really easy.
>
> As I had no success till now I will try to simply embed the non osgi cxf in a service client bundle and re export my service as an
> osgi service. So at least my GUI project will not have to embed all the non osgi jars. This solution is far from optimal but I
> think easier to acomplish than the above.
>
> Greetings
>
> Christian
>
>
> --
>
> Christian Schneider
> ---
> http://www.liquid-reality.de
>
Re: Using CXF in Eclipse RCP
Posted by Christian Schneider <ch...@die-schneider.net>.
Thanks already for the many pointers. This seems quite time consuming
though. I guess the main problem is that the cxf jars define many
dependencies that are not osgi enabled. So if I understand this
correctly I have to configure all dependencies by hand and exclude all
the current non-osgi dependencies. Though I understand that changing
this situation is not really easy.
As I had no success till now I will try to simply embed the non osgi cxf
in a service client bundle and re export my service as an osgi service.
So at least my GUI project will not have to embed all the non osgi jars.
This solution is far from optimal but I think easier to acomplish than
the above.
Greetings
Christian
--
Christian Schneider
---
http://www.liquid-reality.de
Re: Using CXF in Eclipse RCP
Posted by Oisin Hurley <oi...@gmail.com>.
> I am trying to call web services from an Eclipse RCP application. Is there a
> howto about this?
I think the best approach is to create a plain java client for
your webservice, then turn that into an OSGi bundle. Then you
can be sure at least that the webservice client part is
functional.
The cxf-bundle will be lazy-activated by Eclipse when one of
its exported classes are loaded.
You will also need to get hold of the various javax.* packages
for the classes CXF needs - check out the Spring bundle
repo [0] or the Orbit bundle library [1] for plugins that do the
necessary.
> Do you have any hints for further reading?
A decent amount of information on the google:
Here's some information on putting a client into smx4 which
because it is OSGi too, has many similarities in terms of the
dependencies and manifest construction: [2,6]
Some distributed OSGi examples, which are [3,4]
At the end of this thread there are a bag-o-links [5]
good luck
--oh
[0] http://www.springsource.com/repository/app/
[1] http://download.eclipse.org/tools/orbit/downloads/
[2] http://old.nabble.com/I've-created-an-example-of-implementing-a-jaxws-client-using-CXF-for--deployment-into-smx4-(servicemix4)-p23156007.html
[3] http://cxf.apache.org/distributed-osgi-greeter-demo-walkthrough.html
[4] http://www.ibm.com/developerworks/webservices/library/ws-OSGi/index.html
[5] http://old.nabble.com/Trouble-wireing-up-Spring-DM-Server---CXF-in-Eclipse-(with-Maven-support)-td26032499.html
[6] http://servicemix.apache.org/SMX4/cxf-examples.html