Hi,

I have a problem with JAXRSServerFactoryBean.

I have a tiny RESTful webservice :

    @POST
    @Path("/computation")
    @Consumes(MediaType.TEXT_XML)
    @Produces(MediaType.TEXT_XML)
    @Override
    public Response compute(Request request) {
      // do stuff and then respond
    }

It works perfectly well when I use Spring (and CXFServlet within a Tomcat container), like this :

    <jaxrs:server id="computationRESTService" address="/">
        <jaxrs:features>
            <cxf:logging/>
        </jaxrs:features>
        <jaxrs:serviceBeans>
            <ref bean="computationService"/>
        </jaxrs:serviceBeans>
        <jaxrs:schemaLocations>

<jaxrs:schemaLocation>classpath:schemas/webservice-request.xsd</jaxrs:schemaLocation>
        </jaxrs:schemaLocations>
    </jaxrs:server>

There's no problem at all with this configuration.
But when I try to launch the server programmatically without Spring, like this :

        JAXRSServerFactoryBean sfb = new JAXRSServerFactoryBean();
        sfb.setResourceClasses(RestComputationService.class);
        sfb.setResourceProvider(RestComputationService.class,
new SingletonResourceProvider(RestComputationService.class));
        sfb.setAddress(BASE_URL);

BindingFactoryManager manager = sfb.getBus().getExtension(BindingFactoryManager.class);
        JAXRSBindingFactory factory = new JAXRSBindingFactory();
        factory.setBus(sfb.getBus());

manager.registerBindingFactory(JAXRSBindingFactory.JAXRS_BINDING_ID, factory);

        Server server = sfb.create();
        server.start();

Each time I try an POST method - that is the same I use to do with my Spring/Tomcat configuration - I get this error :

org.apache.cxf.interceptor.Fault: object is not an instance of declaring class while invoking public server.webservice.model.response.Response server.RestComputationService.compute(server.webservice.model.request.Request) with params [server.webservice.model.request.Request@413fc6].

I'm sure I'm missing something in my code.
Can anyone tell me what I'm missing/doing wrong ?

Regards.
--
Pensez environnement : limitez l'impression de ce mail.
Please don't print this e-mail unless you really need to.

Reply via email to