CXF in combination with OSGi HTTP Service

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

CXF in combination with OSGi HTTP Service

Alexander Broekhuis-2
Hi all,

I'm trying to get CXF to work with OSGi and the HTTP Service. While I can
get the bundles to run in my OSGi instance (Felix), I am not able to get my
own Endpoints registered.

I created a custom servlet that extends the CXFNonSpringServlet. In this
servlet I create Endpoints using Endpoint.publish.
This is where I run into the problem that the default Java Endpoint
publisher is used, and not the CXF one.

The following exception is thrown:

"java.lang.IllegalArgumentException: Cannot create URL for this address
/TestResource

at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.publish(
EndpointImpl.java:222)"

What is the right way to get the proper Endpoint publisher?

--
Met vriendelijke groet,

Alexander Broekhuis
Reply | Threaded
Open this post in threaded view
|

Re: CXF in combination with OSGi HTTP Service

Francois Papon
Hi Alexander,

Which HTTP Service impl do you use in Felix ?

François


Le 30/01/2018 à 13:33, Alexander Broekhuis a écrit :

> Hi all,
>
> I'm trying to get CXF to work with OSGi and the HTTP Service. While I can
> get the bundles to run in my OSGi instance (Felix), I am not able to get my
> own Endpoints registered.
>
> I created a custom servlet that extends the CXFNonSpringServlet. In this
> servlet I create Endpoints using Endpoint.publish.
> This is where I run into the problem that the default Java Endpoint
> publisher is used, and not the CXF one.
>
> The following exception is thrown:
>
> "java.lang.IllegalArgumentException: Cannot create URL for this address
> /TestResource
>
> at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.publish(
> EndpointImpl.java:222)"
>
> What is the right way to get the proper Endpoint publisher?
>

Reply | Threaded
Open this post in threaded view
|

Re: CXF in combination with OSGi HTTP Service

Carlos Sierra Andrés-2
In reply to this post by Alexander Broekhuis-2
Hi Alexander,

I would say that the javax.xml.ws.spi.Provider being used is not the one
in CXF but the JDK's one.

If you are working in a OSGi environment you should try to make sure the
Thread Context Class Loader is set to the one of the bundle that
provider CXF's Provider implementation, normally the one that carries
the META-INF/service/javax.xml.ws.spi.Provider file.

From that point on I guess the only thing you need to do is to properly
attach the corresponding Bus to the CXFNonSpringServlet.

Hope this helps.

Carlos.


El 30/1/18 a las 10:33, Alexander Broekhuis escribió:

> Hi all,
>
> I'm trying to get CXF to work with OSGi and the HTTP Service. While I can
> get the bundles to run in my OSGi instance (Felix), I am not able to get my
> own Endpoints registered.
>
> I created a custom servlet that extends the CXFNonSpringServlet. In this
> servlet I create Endpoints using Endpoint.publish.
> This is where I run into the problem that the default Java Endpoint
> publisher is used, and not the CXF one.
>
> The following exception is thrown:
>
> "java.lang.IllegalArgumentException: Cannot create URL for this address
> /TestResource
>
> at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.publish(
> EndpointImpl.java:222)"
>
> What is the right way to get the proper Endpoint publisher?
>

Reply | Threaded
Open this post in threaded view
|

Re: CXF in combination with OSGi HTTP Service

Alexander Broekhuis-2
Hi Carlos,

2018-01-31 14:52 GMT+01:00 <[hidden email]>:

> Hi Alexander,
>
> I would say that the javax.xml.ws.spi.Provider being used is not the one
> in CXF but the JDK's one.
>

Makes sense, seemed to be the problem yes.


>
> If you are working in a OSGi environment you should try to make sure the
> Thread Context Class Loader is set to the one of the bundle that
> provider CXF's Provider implementation, normally the one that carries
> the META-INF/service/javax.xml.ws.spi.Provider file.
>

I've now set the TCCL explicitly to the classloader of the CXF provider's
class, and that did indeed do the trick!


>
> From that point on I guess the only thing you need to do is to properly
> attach the corresponding Bus to the CXFNonSpringServlet.
>

I already had this one in place, with the needed extensions, so fixed the
classloader was the last thing to do!


>
> Hope this helps.
>

Definitely! Thanks for the pointers!


>
> Carlos.
>
>
> El 30/1/18 a las 10:33, Alexander Broekhuis escribió:
> > Hi all,
> >
> > I'm trying to get CXF to work with OSGi and the HTTP Service. While I can
> > get the bundles to run in my OSGi instance (Felix), I am not able to get
> my
> > own Endpoints registered.
> >
> > I created a custom servlet that extends the CXFNonSpringServlet. In this
> > servlet I create Endpoints using Endpoint.publish.
> > This is where I run into the problem that the default Java Endpoint
> > publisher is used, and not the CXF one.
> >
> > The following exception is thrown:
> >
> > "java.lang.IllegalArgumentException: Cannot create URL for this address
> > /TestResource
> >
> > at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.publish(
> > EndpointImpl.java:222)"
> >
> > What is the right way to get the proper Endpoint publisher?
> >
>
>


--
Met vriendelijke groet,

Alexander Broekhuis
Reply | Threaded
Open this post in threaded view
|

Re: CXF in combination with OSGi HTTP Service

Carlos Sierra Andrés-2
Hey... glad to hear that!


El 1/2/18 a las 9:13, Alexander Broekhuis escribió:

> Hi Carlos,
>
> 2018-01-31 14:52 GMT+01:00 <[hidden email]>:
>
>> Hi Alexander,
>>
>> I would say that the javax.xml.ws.spi.Provider being used is not the one
>> in CXF but the JDK's one.
>>
> Makes sense, seemed to be the problem yes.
>
>
>> If you are working in a OSGi environment you should try to make sure the
>> Thread Context Class Loader is set to the one of the bundle that
>> provider CXF's Provider implementation, normally the one that carries
>> the META-INF/service/javax.xml.ws.spi.Provider file.
>>
> I've now set the TCCL explicitly to the classloader of the CXF provider's
> class, and that did indeed do the trick!
>
>
>> From that point on I guess the only thing you need to do is to properly
>> attach the corresponding Bus to the CXFNonSpringServlet.
>>
> I already had this one in place, with the needed extensions, so fixed the
> classloader was the last thing to do!
>
>
>> Hope this helps.
>>
> Definitely! Thanks for the pointers!
>
>
>> Carlos.
>>
>>
>> El 30/1/18 a las 10:33, Alexander Broekhuis escribió:
>>> Hi all,
>>>
>>> I'm trying to get CXF to work with OSGi and the HTTP Service. While I can
>>> get the bundles to run in my OSGi instance (Felix), I am not able to get
>> my
>>> own Endpoints registered.
>>>
>>> I created a custom servlet that extends the CXFNonSpringServlet. In this
>>> servlet I create Endpoints using Endpoint.publish.
>>> This is where I run into the problem that the default Java Endpoint
>>> publisher is used, and not the CXF one.
>>>
>>> The following exception is thrown:
>>>
>>> "java.lang.IllegalArgumentException: Cannot create URL for this address
>>> /TestResource
>>>
>>> at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.publish(
>>> EndpointImpl.java:222)"
>>>
>>> What is the right way to get the proper Endpoint publisher?
>>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: CXF in combination with OSGi HTTP Service

Carlos Sierra Andrés-2
In reply to this post by Alexander Broekhuis-2
Hey... glad to hear that!

Carlos.


El 1/2/18 a las 9:13, Alexander Broekhuis escribió:

> Hi Carlos,
>
> 2018-01-31 14:52 GMT+01:00 <[hidden email]>:
>
>> Hi Alexander,
>>
>> I would say that the javax.xml.ws.spi.Provider being used is not the one
>> in CXF but the JDK's one.
>>
> Makes sense, seemed to be the problem yes.
>
>
>> If you are working in a OSGi environment you should try to make sure the
>> Thread Context Class Loader is set to the one of the bundle that
>> provider CXF's Provider implementation, normally the one that carries
>> the META-INF/service/javax.xml.ws.spi.Provider file.
>>
> I've now set the TCCL explicitly to the classloader of the CXF provider's
> class, and that did indeed do the trick!
>
>
>> From that point on I guess the only thing you need to do is to properly
>> attach the corresponding Bus to the CXFNonSpringServlet.
>>
> I already had this one in place, with the needed extensions, so fixed the
> classloader was the last thing to do!
>
>
>> Hope this helps.
>>
> Definitely! Thanks for the pointers!
>
>
>> Carlos.
>>
>>
>> El 30/1/18 a las 10:33, Alexander Broekhuis escribió:
>>> Hi all,
>>>
>>> I'm trying to get CXF to work with OSGi and the HTTP Service. While I can
>>> get the bundles to run in my OSGi instance (Felix), I am not able to get
>> my
>>> own Endpoints registered.
>>>
>>> I created a custom servlet that extends the CXFNonSpringServlet. In this
>>> servlet I create Endpoints using Endpoint.publish.
>>> This is where I run into the problem that the default Java Endpoint
>>> publisher is used, and not the CXF one.
>>>
>>> The following exception is thrown:
>>>
>>> "java.lang.IllegalArgumentException: Cannot create URL for this address
>>> /TestResource
>>>
>>> at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.publish(
>>> EndpointImpl.java:222)"
>>>
>>> What is the right way to get the proper Endpoint publisher?
>>>
>>
>