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:[email protected]
Web: fusesource.com
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com









Reply via email to