Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

365
Vistas
How to use the context Path in Camel routes?

i am new to camel. i am doing a project in spring-boot using camel for routes. I noticed that when I go to SwaggerUi to see the correct functioning of my Post calls the contextPath of the routes does not work:

public void configure() {

        restConfiguration().component("servlet").contextPath("service/");

        rest("/ocs")
            .post("/homologation")
                .id(camelRoutesIdConfig.getHomologationRequestRouteId())
                .consumes("application/json")
                .produces("application/json")
                .param()
                    .name("IntegrationRequestDto")
                    .type(RestParamType.body)
                    .required(true)
                    .description("attivazione nuovo contratto sul portale")
                .endParam()
                .to("direct:homologation")

}

This problem does not occur if in the application.yml I specify the contextPath like this:

camel:
  rest:
    component: servlet
    binding-mode: json
    enable-cors: true
    data-format-property:
      prettyPrint: false
     component:
    servlet:
      mapping:
        context-path: /service/*

When I make my call Post in one case it works, while in the case of ContextPath in routes it doesn't recognize the command and gives

{
  "timestamp": "2020-11-22T17:44:26.701+0000",
  "status": 404,
  "error": "Not Found",
  "message": "Not Found",
  "path": "/service/ocs/homologation"
}

Why is there this problem? Why am I forced to also specify in the application.yml instead of using it only once in the routes? Thanks to everyone for a possible answer

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

It is right that it works like this. the contextPath configuration in the RestConfiguration is for pure XML-API documentation. To activate the contextPath in your calls Get, Post, Put ... you need to specify it in the application.properties. Apache Camel's documentation on using the servlet may help you

over 4 years ago · Santiago Trujillo Denunciar

0

add property configuration on application.properties :

camel.component.servlet.mapping.context-path=/camel-rest-example/*

and then call

http://localhost:8080/camel-rest-example/${your-resource-here}

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda