16 November 2017

Apache Camel REST Endpoint and Servlet Name

This problem took me a few hours to solve at my current client.

Apache Camel provides a way to expose routes as REST endpoints:


restConfiguration().component("servlet");

rest("start")
        .get()
        .route().routeId("esb-parisbridge rest")
        .to("direct:start")
        .setHeader(Exchange.HTTP_RESPONSE_CODE, constant(200))
        .transform(constant("Completed Request successfully"));


Now when you are deploying multiple WARs into one app server the CamelHttpTransportServlet is there multiple times with the same name.
To make this work you need to rename the servlet name to a unique name:

<servlet>
    <display-name>Camel Http Transport Servlet</display-name>
    <servlet-name>CamelServletParisBridge</servlet-name>
    <servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>CamelServletParisBridge</servlet-name>
    <url-pattern>/camel/*</url-pattern>
</servlet-mapping>

The problem now is that Camel does not know about the changed name and you will get a 404 not found when trying to access the REST endpoint.

You must tell the Camel servlet component what the name of the servlet will be:

restConfiguration().component("servlet")
  .endpointProperty("servletName", "CamelServletParisBridge");

30 September 2017

AWS EC2 Container Services: denied: Your Authorization Token has expired. Please run 'aws ecr get-login' to fetch a new one.

Today I tried to push my docker image to AWS but constantly get the error:
denied: Your Authorization Token has expired. Please run 'aws ecr get-login' to fetch a new one.

There seems to be a bug because when I looked at the generated key I saw

docker login -u AWS -p <key> -e none https://xxx.dkr.ecr.us-west-2.amazonaws.com

The problem is -e none.

If you have the same problem just copy the request and execute it without -e none.
That's it!