Hi,

how to reproduce: use a fresh KAraf 4.1.1 standard installation. Add the
mvn:org.apache.cxf.karaf/apache-cxf/3.1.12/xml/features repo and the cxf
feature to org.apache.karaf.feature.cfg and start Karaf.

Create a bundle (I named it org.test.cxftestbundle) with following blueprint
file:

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xmlns:jaxws="http://cxf.apache.org/blueprint/jaxws";
        xmlns:jaxrs="http://cxf.apache.org/blueprint/jaxrs";
        xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration";
        xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
                                                
http://cxf.apache.org/blueprint/jaxws
http://cxf.apache.org/schemas/blueprint/jaxws.xsd
                                                
http://cxf.apache.org/blueprint/jaxrs
http://cxf.apache.org/schemas/blueprint/jaxrs.xsd
                                                
http://cxf.apache.org/transports/http-jetty/configuration
http://cxf.apache.org/schemas/configuration/http-jetty.xsd
                                                
http://cxf.apache.org/blueprint/core
http://cxf.apache.org/schemas/blueprint/core.xsd";>

        <bean id="jaxbProvider"
class="org.apache.cxf.jaxrs.provider.json.JSONProvider">
                <property name="writeXsiType" value="false"/> 
        </bean>
        
        <jaxrs:server id="myRestServiceServ" address="http://localhost:9999";
depends-on="rest-config">
                <jaxrs:serviceBeans>
                     <ref component-id="myRestService"/>
                </jaxrs:serviceBeans>
                <jaxrs:providers>
                <ref component-id="jaxbProvider"/>
                </jaxrs:providers>
        </jaxrs:server>
     
        <bean id="myRestService" class="org.test.cxftestbundle.MyRestService">
        </bean>

        <httpj:engine-factory id="rest-config">
                <httpj:engine port="9999">
                </httpj:engine>
        </httpj:engine-factory>

</blueprint>

MyRestService can just be an empty class. Install the bundle and start it.
It will lead to the exception mentioned above as long as the compatibility
bundle is not installed. Please note that this simple example will also not
start correctly with the compatibility bundle due to missing implementation
of the rest service class, but it doesn't stumble over the class not found
exception any longer.

Best Regards,
Jochen

P.S.: to make it fully work with the compatibility bundle, the MyRestService
class can e.g. be

package org.test.cxftestbundle;

import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;

import org.json.JSONObject;

@Path("somepath")
public class MyRestService {

        @POST
        @Path("/somepost")
        @Produces(MediaType.APPLICATION_JSON)
        public String getSomething(@Context HttpHeaders headers) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("ObjectID", "4711");
                jsonObject.put("ObjectName", "First Object");
                return jsonObject.toString();
        }

}


But then you also have to install org.json/json in Karaf to meet the
dependencies.



--
View this message in context: 
http://karaf.922171.n3.nabble.com/Karaf-4-1-1-and-CXF-3-1-12-tp4051041p4051064.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Reply via email to