You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by ChrisBarsouk <el...@web.de> on 2012/01/04 15:19:21 UTC

Re: Exception on bean configuration

Thank you for your response.

I debugged into the problem and it turns out the reason was a
ClassNotFoundException which was nastily  cut from the stack trace. I had to
add the org.apache.cxf.jaxrs.impl.RuntimeDelegateImpl to my MANIFEST.MF.

After some more selfmade issues it suddenly worked although I didn't change
much. Again after many tries it turned out that 2 HttpServiceContexts were
started. First the CXFServlet from my com.cbs.ui.rest bundle and then
another Servlet from the org.apache.cxf.bundle-jaxrs and only if my bundle
is registering its servlet last the service works. I still do not understand
how this can work if it has no knowledge of my ManagerService bean.

I thought: 2 servlets is one too many and killed this part (my servlet):
    <osgi:service interface="javax.servlet.Servlet">
        <osgi:service-properties>
            <entry key="filterMappingUrlPattern" value="/cbs_rest/*" />
            <entry key="alias" value="/cbs_rest/*" />
            <entry key="servlet-name" value="CXFServlet" />
            <entry key="debug" value="2" />
        </osgi:service-properties>
        <bean class="org.apache.cxf.transport.servlet.CXFServlet"></bean>
    </osgi:service>

and I had also found out that the servlet from the
org.apache.cxf.bundle-jaxrs is found under the path /cfx. Now I get the
response: No service was found. And the server logs: Can't find the the
request for http://localhost:8080/cxf/managerservice/sites's Observer

Another thing I still do not understand is how the alias and the
filterMappingUrlPattern can be set for the jaxrs:server element.

I hope you see more light than I do.

Chris

--
View this message in context: http://cxf.547215.n5.nabble.com/Exception-on-bean-configuration-tp5094705p5119703.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Exception on bean configuration

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 13/01/12 15:31, ChrisBarsouk wrote:
> It is working now.
>
> 1. ServiceMix jsr311-api-1.1.1 bundle
> I have this bundle added but I still had to copy the
> javax.ws.rs.ext.RuntimeDelegate into my bundles META_INF/services directory.
> It just did not pick up the file inside the cxf-bundle-jaxrs. Maybe a race
> condition...
>

Can you try a 1.9.0 version ? I've never had to do it myself, but a race 
condition was reported just a day or so ago with the earlier specs and 
this is apparently fixed in 1.9.0

> 2. OSGi
> Yes, I did have to install more bundles: org.apache.neethi and
> javax.ws.rs.jsr311-api.
>
> 3. Changing the alias
> For those who (like me) do not understand right away how to do it:
> Add a new file named org.apache.cxf.osgi.cfg to the Felix load directory
> with the following content:
> org.apache.cxf.servlet.context=/your_desired_alias
>
> Now we are working on registering our Spring security filter chain with the
> cxf servlet.
> Our not so clean solution: We get the CXF bundle from the bundle context and
> then register our SpringFilterChain.
>

In DOSGi RI it is possible to register Filters as OSGI services. We will 
get the same approach supported once frontend-specific activators are 
introduced

thanks, Sergey

> I hope this may help others, too.
>
> Cheers
> Chris
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Exception-on-bean-configuration-tp5094705p5142845.html
> Sent from the cxf-user mailing list archive at Nabble.com.


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Re: Exception on bean configuration

Posted by ChrisBarsouk <el...@web.de>.
It is working now.

1. ServiceMix jsr311-api-1.1.1 bundle
I have this bundle added but I still had to copy the
javax.ws.rs.ext.RuntimeDelegate into my bundles META_INF/services directory.
It just did not pick up the file inside the cxf-bundle-jaxrs. Maybe a race
condition...

2. OSGi
Yes, I did have to install more bundles: org.apache.neethi and
javax.ws.rs.jsr311-api.

3. Changing the alias
For those who (like me) do not understand right away how to do it:
Add a new file named org.apache.cxf.osgi.cfg to the Felix load directory
with the following content:
org.apache.cxf.servlet.context=/your_desired_alias

Now we are working on registering our Spring security filter chain with the
cxf servlet.
Our not so clean solution: We get the CXF bundle from the bundle context and
then register our SpringFilterChain.

I hope this may help others, too.

Cheers
Chris

--
View this message in context: http://cxf.547215.n5.nabble.com/Exception-on-bean-configuration-tp5094705p5142845.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Exception on bean configuration

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

You don't need expose javax.servlet.Servlet OSGi service from your  
customer bundle yourself, it's already done when start cxf bundle,  
which leverage the underlying http-osgi service, and your customer  
bundle just use it.

So configuration
<osgi:service interface="javax.servlet.Servlet">
        <osgi:service-properties>
            <entry key="filterMappingUrlPattern" value="/cbs_rest/*" />
            <entry key="alias" value="/cbs_rest/*" />
            <entry key="servlet-name" value="CXFServlet" />
            <entry key="debug" value="2" />
        </osgi:service-properties>
        <bean class="org.apache.cxf.transport.servlet.CXFServlet"></ 
bean>
    </osgi:service>
is unnecessary  from your bundle-context.xml.

Btw, just FYI, to use cxf in OSGi container, you need install lots of  
bundles besides the cxf bundle, so figure out all those bundles and  
install them isn't a simple task(especially some dependencies are not  
bundles yet, so you need wrap them or use the one from other  bundle  
repositories,  like what servicemix can provide), I suggest you use  
Karaf/Serivicemix which can install cxf features easily(here feature  
is a provision concept from Karaf, and it include all necessary  
bundles for a certain featur), also in Servicemix there's a cxf-jaxrs  
example, which is working out-of-box and it should be a good start for  
you.

Freeman
On 2012-1-4, at 下午10:19, ChrisBarsouk wrote:

> Thank you for your response.
>
> I debugged into the problem and it turns out the reason was a
> ClassNotFoundException which was nastily  cut from the stack trace.  
> I had to
> add the org.apache.cxf.jaxrs.impl.RuntimeDelegateImpl to my  
> MANIFEST.MF.
>
> After some more selfmade issues it suddenly worked although I didn't  
> change
> much. Again after many tries it turned out that 2  
> HttpServiceContexts were
> started. First the CXFServlet from my com.cbs.ui.rest bundle and then
> another Servlet from the org.apache.cxf.bundle-jaxrs and only if my  
> bundle
> is registering its servlet last the service works. I still do not  
> understand
> how this can work if it has no knowledge of my ManagerService bean.
>
> I thought: 2 servlets is one too many and killed this part (my  
> servlet):
>    <osgi:service interface="javax.servlet.Servlet">
>        <osgi:service-properties>
>            <entry key="filterMappingUrlPattern" value="/cbs_rest/*" />
>            <entry key="alias" value="/cbs_rest/*" />
>            <entry key="servlet-name" value="CXFServlet" />
>            <entry key="debug" value="2" />
>        </osgi:service-properties>
>        <bean class="org.apache.cxf.transport.servlet.CXFServlet"></ 
> bean>
>    </osgi:service>
>
> and I had also found out that the servlet from the
> org.apache.cxf.bundle-jaxrs is found under the path /cfx. Now I get  
> the
> response: No service was found. And the server logs: Can't find the  
> the
> request for http://localhost:8080/cxf/managerservice/sites's Observer
>
> Another thing I still do not understand is how the alias and the
> filterMappingUrlPattern can be set for the jaxrs:server element.
>
> I hope you see more light than I do.
>
> Chris
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Exception-on-bean-configuration-tp5094705p5119703.html
> Sent from the cxf-user mailing list archive at Nabble.com.

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

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










Re: Exception on bean configuration

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi,

On 04/01/12 16:19, ChrisBarsouk wrote:
> Thank you for your response.
>
> I debugged into the problem and it turns out the reason was a
> ClassNotFoundException which was nastily  cut from the stack trace. I had to
> add the org.apache.cxf.jaxrs.impl.RuntimeDelegateImpl to my MANIFEST.MF.
>

Which class was missing ? I'm not sure having to import 
RuntimeDelegateImpl is really needed, may be you need to get a 
ServiceMix jsr311-api-1.1.1 bundle added ?

> After some more selfmade issues it suddenly worked although I didn't change
> much. Again after many tries it turned out that 2 HttpServiceContexts were
> started. First the CXFServlet from my com.cbs.ui.rest bundle and then
> another Servlet from the org.apache.cxf.bundle-jaxrs and only if my bundle
> is registering its servlet last the service works.

Is it somehow possible to get a custom servlet context registered before 
the default one is registered, as part of the cxf bundle registration ? 
Sorry if I miss something...

> I still do not understand
> how this can work if it has no knowledge of my ManagerService bean.

I suppose you were using a '/cbs_rest' context which is handled by the 
registration below ?

>
> I thought: 2 servlets is one too many and killed this part (my servlet):
>      <osgi:service interface="javax.servlet.Servlet">
>          <osgi:service-properties>
>              <entry key="filterMappingUrlPattern" value="/cbs_rest/*" />
>              <entry key="alias" value="/cbs_rest/*" />
>              <entry key="servlet-name" value="CXFServlet" />
>              <entry key="debug" value="2" />
>          </osgi:service-properties>
>          <bean class="org.apache.cxf.transport.servlet.CXFServlet"></bean>
>      </osgi:service>
>
> and I had also found out that the servlet from the
> org.apache.cxf.bundle-jaxrs is found under the path /cfx.

This alias is configurable, "org.apache.cxf.osgi" is the persistent id. 
For example, we use '/services' by default.

> Now I get the
> response: No service was found. And the server logs: Can't find the the
> request for http://localhost:8080/cxf/managerservice/sites's Observer

What CXF version are you using ? You may need to import an http-osgi 
transport, but this is not needed with the latest CXFs

>
> Another thing I still do not understand is how the alias and the
> filterMappingUrlPattern can be set for the jaxrs:server element.
>

I've actually never used filterMappingUrlPattern, well, I guess I did a 
couple of times but only when restricting the filter mappings in 
web.xml, how does it work in your original configuration ?

Cheers, Sergey

> I hope you see more light than I do.
>
> Chris
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Exception-on-bean-configuration-tp5094705p5119703.html
> Sent from the cxf-user mailing list archive at Nabble.com.


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com