0
votes

I tried very simple Route:

    restConfiguration()
            .component("servlet");

    rest().get("/hello")
            .to("direct:hello");

    from("direct:hello")
            .log(LoggingLevel.INFO, "Hello World")
            .transform().simple("Hello World");

And indeed, when lunching my spring boot application I can see that the route listens to it: [enter image description here][1]

2021-04-14 15:03:31.759 INFO 25248 --- [ main] o.a.c.i.e.InternalRouteStartupManager : Route: route1 started and consuming from: direct://hello 2021-04-14 15:03:31.760 INFO 25248 --- [ main] o.a.c.i.e.InternalRouteStartupManager : Route: route2 started and consuming from: servlet:/hello 2021-04-14 15:03:31.768 INFO 25248 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Total 2 routes, of which 2 are started 2021-04-14 15:03:31.768 INFO 25248 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Apache Camel 3.7.1 (camel-1) started in 220ms

However, when I tried reaching this address, I get 404 error.

{ "timestamp": "2021-04-14T12:17:11.975+00:00", "status": 404, "error": "Not Found", "message": "", "path": "/hello" }

and also in my console: 2021-04-14 15:17:11.973 WARN 25248 --- [nio-8080-exec-4] o.s.web.servlet.PageNotFound : No mapping for GET /hello

Any idea how to solve it? I would say here that I googled this issue and solution like using "camel.component.servlet.mapping.context-path=/* " or using "camel" prefix didn't work for me.

Thanks!

1

1 Answers

0
votes

create a bean like that any configuration class

  @SpringBootApplication
    public class DemoApplication {
        public static void main(String[] args) {
            SpringApplication.run(DemoApplication.class, args);
        }
    
        @Bean
        public ServletRegistrationBean camelServletRegistrationBean() {
            ServletRegistrationBean registration = new ServletRegistrationBean(new CamelHttpTransportServlet(), "/*");
            registration.setName("CamelServlet");
            return registration;
        }}

for example camel rest and spring boot : https://github.com/erayerdem/camelrest