[
https://issues.apache.org/jira/browse/CAMEL-17015?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17422022#comment-17422022
]
Peter Hermsdorf commented on CAMEL-17015:
-----------------------------------------
Basically returning something like this:
{code}
class P4Routes extends RouteBuilder {
@Override
public void configure() throws Exception {
addHello();
}
private void addHello() {
rest("/say")
.get("/hello").to("direct:hello");
from("direct:hello")
.transform().constant("Hello World");
}
}
{code}
The little 'trick' with the OsgiDefaultCamelContext.init method is necessary
because otherwise the routes are not picked up.
> Issue with REST Service after Camel update
> ------------------------------------------
>
> Key: CAMEL-17015
> URL: https://issues.apache.org/jira/browse/CAMEL-17015
> Project: Camel
> Issue Type: Bug
> Components: rest
> Affects Versions: 3.11.2
> Reporter: Peter Hermsdorf
> Priority: Minor
> Fix For: 3.11.3, 3.13.0
>
>
> After updating from Camel 3.4.4 to 3.11.2 our REST Services aren'T working
> anymore.
> Already discussed here:
> https://camel.zulipchat.com/#narrow/stream/257298-camel/topic/Problem.20with.20REST.20services.20after.20upgrading.20to.20Camel.203.2E11.2E2/near/255227937
> Debugging revealed the following:
> we create a Osgi Camel Context and register Routes like this:
> {code:java}
> camelContext = new OsgiDefaultCamelContext(bundleContext) {
> @Override
> public void init() {
> final RouteBuilder routes =
> createRoutes();
>
> routes.restConfiguration().componentProperty("servletName",
> "my.custom.servletName").clientRequestValidation(true);
> this.addRoutes(routes);
> super.init();
> }
> {code}
>
> In org.apache.camel.component.servlet.ServletComponent.connect(HttpConsumer)
> {code}
> sc.getEndpoint().getServletName()
> {code}
> returns the Default Servlet Name {code}CamelServlet{code} and not my
> {code}my.custom.servletName{code} because
> {code}org.apache.camel.component.servlet.ServletEndpoint.setServletName(String){code}
> is called with {code}CamelServlet{code} and not with my custom servletname.
> Seems like no one is setting the correct value on
> {code}org.apache.camel.component.servlet.ServletComponent.setServletName(String){code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)