Issue
The dependencies:
dependencies {
implementation("org.apache.camel:camel-core:3.14.0")
implementation("org.apache.camel:camel-openapi-java:3.14.0")
implementation("com.fasterxml.jackson.core:jackson-core:2.13.1")
implementation("com.fasterxml.jackson.core:jackson-databind:2.13.1")
implementation("com.fasterxml.jackson.core:jackson-annotations:2.13.1")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.apache.camel.springboot:camel-spring-boot-starter:3.14.0")
implementation("org.apache.camel.springboot:camel-servlet-starter:3.14.0")
implementation("org.apache.camel.springboot:camel-jackson-starter:3.14.0")
implementation("org.apache.camel.springboot:camel-http-starter:3.14.0")
implementation("org.apache.camel.springboot:camel-bean-validator-starter:3.14.0")
}
Attempts at changing from prop files:
apache-camel-spring-boot/src/main/resources/application.properties
:
camel.component.servlet.mapping.contextPath=/test/*
camel.component.servlet.mapping.context-path=/test/*
apache-camel-spring-boot/src/main/resources/application.yml
:
camel:
component:
servlet:
mapping:
contextPath: /test/*
The actual REST configuration:
@Component
public class CamelRouter extends RouteBuilder {
@Override
public void configure() throws Exception {
restConfiguration()
.component("servlet")
.contextPath("test")
.host("localhost")
.port(8080)
.bindingMode(RestBindingMode.json)
.enableCORS(true);
rest("/users").description("User REST service")
.produces("application/json")
.get()
.outType(String.class)
.to("bean:myService?method=find")
}
}
But the only URL that works is: http://localhost:8080/camel/users
Why is http://localhost:8080/test/users returning a 404 when I've changed the context path of Camel?
Solution
Added to apache-camel-spring-boot/src/main/resources/application.properties
:
camel.servlet.mapping.context-path=/*
Answered By - bobbyrne01
Answer Checked By - Cary Denson (JavaFixing Admin)