Hi

We have this code in the CXF demo (contributed by a CXF user):

https://github.com/apache/cxf/blob/master/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot/src/main/java/sample/rs/service/SampleRestWSApplication.java

I wonder if the problem is no link exists between Spring DispatcherServlet and the CXF endpoint... Would registering ServletRegistrationBean help ?

Cheers, Sergey
On 02/07/15 22:29, edhansen42 wrote:
I'm trying to get cxfrs and jaxrs to work in a camel-boot app.  I'm using
camel 2.15.2, cxf 3.1.0, and spring boot 1.2.5.RELEASE.

Here's my spring boot router code:
@SpringBootApplication
public class SpringBootRouter extends FatJarRouter {
        @Bean(name="jaxRsServer") @DependsOn("cxf")
        public JAXRSServerFactoryBean jaxRsServer() {
                cxf();
                JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
                factory.setBus(cxf());
                factory.setAddress( "/" );
                List resources = new ArrayList<>();
                resources.add(createResource(MyResource.class));
                factory.setServiceBeans(resources);
                return factory;
        }

        @Bean( destroyMethod = "shutdown" )
        public Bus cxf() {
                return new SpringBus();
        }

        @Override
        public void configure() {
                from("cxfrs:bean:jaxRsServer?bindingStyle=SimpleConsumer")
                        .routeId("My Route")
                        .bean(new MyServiceBean(), "myGet(${header.id})");
        }
        
        public  static <T> T createResource(Class<T> resourceInterface) {
                InvocationHandler h = new InvocationHandler() {
                        public Object invoke(Object proxy, Method method, 
Object[] args)
                                        throws Throwable {
                                return null;
                        }
                };
                
                return (T) 
Proxy.newProxyInstance(resourceInterface.getClassLoader(), new
Class[] {resourceInterface}, h);
        }

Here is my resource:
@Path("/mypath")
public interface MyResource {
        @GET
        @Path("/{id}")
        @ResponseType(MyObject.class)
        public abstract Response doGet(@PathParam("id") String id);
}


Spring reports that the route starts fine:
Route: My Route started and consuming from:
Endpoint[cxfrs://bean:jaxRsServer?bindingStyle=SimpleConsumer]

When I hit the endpoint (http://127.0.0.1:8080/mypath/123), I get the
following response:
{
     "timestamp": 1435871466024,
     "status": 404,
     "error": "Not Found",
     "message": "No message available",
     "path": "/mypath/123"
}

And in the log from Spring, the only result of hitting the endpoint is:
o.s.web.servlet.DispatcherServlet        : FrameworkServlet
'dispatcherServlet': initialization started
o.s.web.servlet.DispatcherServlet        : FrameworkServlet
'dispatcherServlet': initialization completed in 13 ms

Seems like the DispatcherServlet is not passing through the request to my
jaxrs server.

Am I missing some configuration for the DispatcherServlet?





--
View this message in context: 
http://camel.465427.n5.nabble.com/cxfrs-jaxrs-and-camel-boot-tp5768831.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Reply via email to