You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Isuru Suriarachchi <is...@gmail.com> on 2012/03/29 15:47:01 UTC

Do CXF services with JAX-WS handlers work in OSGi?

I'm trying CXF in my OSGi container and looks like JAX-WS handler samples
are not working inside OSGi. When I had a look at the code in
the HandlerChainBuilder class, it uses clz.getResource(filename) to load
the handler file. This fails in OSGi.

protected URL resolveHandlerChainFile(Class clz, String filename) {
        URL handlerFile = clz.getResource(filename);
        if (handlerFile == null) {
            //the file location might be an absolute java.net.URL in
externalForm.
            try {
                handlerFile = new URL(filename);
                //test if the URL can be opened
                handlerFile.openStream();
            } catch (Exception e) {
                //do nothing
            }
        }
        return handlerFile;
    }

Has anyone tried this before? Is there a workaround for this problem?

Thanks,
~Isuru

Re: Do CXF services with JAX-WS handlers work in OSGi?

Posted by Daniel Kulp <dk...@apache.org>.
Can you create a quick "hello world" type example for this that we could use 
as a test case?

Not sure if it's easily fixable though.   Having to load resources via the 
classloaders is a bit difficult in OSGi.   That said, this code likely 
should be using our ClassLoaderUtils to grab that resource.   That MAY allow 
it to work.  Not really sure.   An example would definitely help.

Dan


On Thursday, March 29, 2012 07:17:01 PM Isuru Suriarachchi wrote:
> I'm trying CXF in my OSGi container and looks like JAX-WS handler samples
> are not working inside OSGi. When I had a look at the code in
> the HandlerChainBuilder class, it uses clz.getResource(filename) to load
> the handler file. This fails in OSGi.
> 
> protected URL resolveHandlerChainFile(Class clz, String filename) {
>         URL handlerFile = clz.getResource(filename);
>         if (handlerFile == null) {
>             //the file location might be an absolute java.net.URL in
> externalForm.
>             try {
>                 handlerFile = new URL(filename);
>                 //test if the URL can be opened
>                 handlerFile.openStream();
>             } catch (Exception e) {
>                 //do nothing
>             }
>         }
>         return handlerFile;
>     }
> 
> Has anyone tried this before? Is there a workaround for this problem?
> 
> Thanks,
> ~Isuru
-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com


Re: Do CXF services with JAX-WS handlers work in OSGi?

Posted by Freeman Fang <fr...@gmail.com>.
Hi,

It SHOULD work, we have a testcase in Apache SMX code which  
demonstrate cxf JAX-WS handlers works in OSGi container, you may need  
take a look.

Here's a bundle[1] which include the jax-ws handler client and  
server(it deploy the jaxws handler service endpoint and also export  
client proxy as OSGi service), here's the testcase[2]which hold  
client OSGi service and invoke the jaxws handler service endpoint, the  
testSoapHandlerOsgi method.

[1]https://svn.apache.org/repos/asf/servicemix/smx4/features/trunk/itests/cxf-soap-handler-osgi/
[2]https://svn.apache.org/repos/asf/servicemix/smx4/features/trunk/itests/tests/src/test/java/org/apache/servicemix/examples/IntegrationTest.java

Freeman

On 2012-3-29, at 下午9:47, Isuru Suriarachchi wrote:

> I'm trying CXF in my OSGi container and looks like JAX-WS handler  
> samples
> are not working inside OSGi. When I had a look at the code in
> the HandlerChainBuilder class, it uses clz.getResource(filename) to  
> load
> the handler file. This fails in OSGi.
>
> protected URL resolveHandlerChainFile(Class clz, String filename) {
>        URL handlerFile = clz.getResource(filename);
>        if (handlerFile == null) {
>            //the file location might be an absolute java.net.URL in
> externalForm.
>            try {
>                handlerFile = new URL(filename);
>                //test if the URL can be opened
>                handlerFile.openStream();
>            } catch (Exception e) {
>                //do nothing
>            }
>        }
>        return handlerFile;
>    }
>
> Has anyone tried this before? Is there a workaround for this problem?
>
> Thanks,
> ~Isuru

---------------------------------------------
Freeman Fang

FuseSource
Email:ffang@fusesource.com
Web: fusesource.com
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com