You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Jacob Kristhammar <ja...@conveneer.com> on 2009/06/15 14:02:15 UTC

Using CXF with WSS4J in an OSGi environment.

Hi,

I am trying to use CXF and WSS4J to provide secure web services in a Felix environment.
When doing this I have run into a couple of problems.

I am using the cxf-minimal-bundle which needs javax.xml.ws.spi that I've provide through the geronimo-jaxws_2.1_spec bundle. These packages are using the service provider, META-INF/services pattern to load the correct implementation of javax.xml.ws.spi.Provider (which should be supplied by the cxf bundle). This doesn't work well with OSGi. Since the two bundles have different classloaders it falls back on the default alternative (which is org.apache.axis2.jaxws.spi.Provider, i.e. not what I want).

I've tried to find a solution for this problem without success. I've noticed that other people have experience similar problems but haven't found a solution that lets me use the third party bundles without any modification?

I tried to solve the problem by using the Embed-Dependency instruction to the maven bundle plugin. I've successfully embedded the bundles, but I can't figure out how to make the META-INF/services visible to the other bundle. I figured that putting them in the same bundles would make their resources visible to the bundle classloader. But when the FactoryFinder is trying to find the appropriate implementation I get the following error (the same as before I've bundled the jaxws implementation inside my bundle) :

DEBUG: META-INF/services/javax.xml.ws.spi.Provider (org.apache.felix.moduleloader.ResourceNotFoundException: META-INF/services/javax.xml.ws.spi.Provider)

This is the instructions I give to the bundle plugin.

<plugins>
  <plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <configuration>
      <instructions>
        <Private-Package>foo.impl.ws.*</Private-Package>
        <Bundle-Activator>foo.impl.ws.Activator</Bundle-Activator>
        <Import-Package>*;resolution:=optional</Import-Package>
        <Export-Package>
          org.apache.cxf*;-split-package:=merge-first,
          javax.xml.ws*;-split-package:=merge-first,
          org.springframework*;-split-package:=merge-first
        </Export-Package>
        <Embed-Dependency>
          cxf-bundle-minimal;inline=META-INF/**/*,
          geronimo-jaxws_2.1_spec;inline=META-INF/**/*,
          org.apache.servicemix.specs.jaxws-api-2.1;inline=META-INF/**/*,
          spring-*;inline=META-INF/**/*
        </Embed-Dependency>
        <Embed-Transitive>false</Embed-Transitive>
      </instructions>
    </configuration>
  </plugin>

I'm open to all kinds of suggestions on how to tackle this problem.
I managed to get around the problem above my manually specifying which implementation to use in system.properties, but then I experienced similar problems with some of the spring packages hence those are included in the example above tool.
I really feel that it should be possible to embed the dependencies inside my bundle to unify the classpath/loader.

BR,
Jacob

RE: Using CXF with WSS4J in an OSGi environment.

Posted by Jacob Kristhammar <ja...@conveneer.com>.
Thanks a lot, that worked great!

Now I've seem to run into another (maybe) related problem. I've posted the question here http://www.nabble.com/Trouble-with-publication-of-web-service-with-WSS4J-in-OSGi-td24069879.html . I'm not sure which list is most appropriate.

BR,
Jacob

-----Original Message-----
From: Guillaume Nodet [mailto:gnodet@gmail.com] 
Sent: den 15 juni 2009 19:16
To: users@felix.apache.org
Subject: Re: Using CXF with WSS4J in an OSGi environment.

You should use the servicemix version of those specifications.
Those are OSGi bundles, but slightly enhanced to leverage the
META-INF/services discovery mechanism in OSGi.
Try installing the following jar instead of the geronimo one:
   http://repo2.maven.org/maven2/org/apache/servicemix/specs/org.apache.servicemix.specs.jaxws-api-2.1/1.3.0/org.apache.servicemix.specs.jaxws-api-2.1-1.3.0.jar

On Mon, Jun 15, 2009 at 14:02, Jacob
Kristhammar<ja...@conveneer.com> wrote:
> Hi,
>
> I am trying to use CXF and WSS4J to provide secure web services in a Felix environment.
> When doing this I have run into a couple of problems.
>
> I am using the cxf-minimal-bundle which needs javax.xml.ws.spi that I've provide through the geronimo-jaxws_2.1_spec bundle. These packages are using the service provider, META-INF/services pattern to load the correct implementation of javax.xml.ws.spi.Provider (which should be supplied by the cxf bundle). This doesn't work well with OSGi. Since the two bundles have different classloaders it falls back on the default alternative (which is org.apache.axis2.jaxws.spi.Provider, i.e. not what I want).
>
> I've tried to find a solution for this problem without success. I've noticed that other people have experience similar problems but haven't found a solution that lets me use the third party bundles without any modification?
>
> I tried to solve the problem by using the Embed-Dependency instruction to the maven bundle plugin. I've successfully embedded the bundles, but I can't figure out how to make the META-INF/services visible to the other bundle. I figured that putting them in the same bundles would make their resources visible to the bundle classloader. But when the FactoryFinder is trying to find the appropriate implementation I get the following error (the same as before I've bundled the jaxws implementation inside my bundle) :
>
> DEBUG: META-INF/services/javax.xml.ws.spi.Provider (org.apache.felix.moduleloader.ResourceNotFoundException: META-INF/services/javax.xml.ws.spi.Provider)
>
> This is the instructions I give to the bundle plugin.
>
> <plugins>
>  <plugin>
>    <groupId>org.apache.felix</groupId>
>    <artifactId>maven-bundle-plugin</artifactId>
>    <configuration>
>      <instructions>
>        <Private-Package>foo.impl.ws.*</Private-Package>
>        <Bundle-Activator>foo.impl.ws.Activator</Bundle-Activator>
>        <Import-Package>*;resolution:=optional</Import-Package>
>        <Export-Package>
>          org.apache.cxf*;-split-package:=merge-first,
>          javax.xml.ws*;-split-package:=merge-first,
>          org.springframework*;-split-package:=merge-first
>        </Export-Package>
>        <Embed-Dependency>
>          cxf-bundle-minimal;inline=META-INF/**/*,
>          geronimo-jaxws_2.1_spec;inline=META-INF/**/*,
>          org.apache.servicemix.specs.jaxws-api-2.1;inline=META-INF/**/*,
>          spring-*;inline=META-INF/**/*
>        </Embed-Dependency>
>        <Embed-Transitive>false</Embed-Transitive>
>      </instructions>
>    </configuration>
>  </plugin>
>
> I'm open to all kinds of suggestions on how to tackle this problem.
> I managed to get around the problem above my manually specifying which implementation to use in system.properties, but then I experienced similar problems with some of the spring packages hence those are included in the example above tool.
> I really feel that it should be possible to embed the dependencies inside my bundle to unify the classpath/loader.
>
> BR,
> Jacob
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Using CXF with WSS4J in an OSGi environment.

Posted by Guillaume Nodet <gn...@gmail.com>.
You should use the servicemix version of those specifications.
Those are OSGi bundles, but slightly enhanced to leverage the
META-INF/services discovery mechanism in OSGi.
Try installing the following jar instead of the geronimo one:
   http://repo2.maven.org/maven2/org/apache/servicemix/specs/org.apache.servicemix.specs.jaxws-api-2.1/1.3.0/org.apache.servicemix.specs.jaxws-api-2.1-1.3.0.jar

On Mon, Jun 15, 2009 at 14:02, Jacob
Kristhammar<ja...@conveneer.com> wrote:
> Hi,
>
> I am trying to use CXF and WSS4J to provide secure web services in a Felix environment.
> When doing this I have run into a couple of problems.
>
> I am using the cxf-minimal-bundle which needs javax.xml.ws.spi that I've provide through the geronimo-jaxws_2.1_spec bundle. These packages are using the service provider, META-INF/services pattern to load the correct implementation of javax.xml.ws.spi.Provider (which should be supplied by the cxf bundle). This doesn't work well with OSGi. Since the two bundles have different classloaders it falls back on the default alternative (which is org.apache.axis2.jaxws.spi.Provider, i.e. not what I want).
>
> I've tried to find a solution for this problem without success. I've noticed that other people have experience similar problems but haven't found a solution that lets me use the third party bundles without any modification?
>
> I tried to solve the problem by using the Embed-Dependency instruction to the maven bundle plugin. I've successfully embedded the bundles, but I can't figure out how to make the META-INF/services visible to the other bundle. I figured that putting them in the same bundles would make their resources visible to the bundle classloader. But when the FactoryFinder is trying to find the appropriate implementation I get the following error (the same as before I've bundled the jaxws implementation inside my bundle) :
>
> DEBUG: META-INF/services/javax.xml.ws.spi.Provider (org.apache.felix.moduleloader.ResourceNotFoundException: META-INF/services/javax.xml.ws.spi.Provider)
>
> This is the instructions I give to the bundle plugin.
>
> <plugins>
>  <plugin>
>    <groupId>org.apache.felix</groupId>
>    <artifactId>maven-bundle-plugin</artifactId>
>    <configuration>
>      <instructions>
>        <Private-Package>foo.impl.ws.*</Private-Package>
>        <Bundle-Activator>foo.impl.ws.Activator</Bundle-Activator>
>        <Import-Package>*;resolution:=optional</Import-Package>
>        <Export-Package>
>          org.apache.cxf*;-split-package:=merge-first,
>          javax.xml.ws*;-split-package:=merge-first,
>          org.springframework*;-split-package:=merge-first
>        </Export-Package>
>        <Embed-Dependency>
>          cxf-bundle-minimal;inline=META-INF/**/*,
>          geronimo-jaxws_2.1_spec;inline=META-INF/**/*,
>          org.apache.servicemix.specs.jaxws-api-2.1;inline=META-INF/**/*,
>          spring-*;inline=META-INF/**/*
>        </Embed-Dependency>
>        <Embed-Transitive>false</Embed-Transitive>
>      </instructions>
>    </configuration>
>  </plugin>
>
> I'm open to all kinds of suggestions on how to tackle this problem.
> I managed to get around the problem above my manually specifying which implementation to use in system.properties, but then I experienced similar problems with some of the spring packages hence those are included in the example above tool.
> I really feel that it should be possible to embed the dependencies inside my bundle to unify the classpath/loader.
>
> BR,
> Jacob
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org