[Solved] org.apache.camel.FailedToCreateRouteException: Failed to create route route1: Route(route1)[From[sendEmail] -> [To[smtps://smtp.gmail.com:… because of No endpoint could be found for: sendEmail, please check your classpath contains the needed Camel component jar.


org.apache.camel.FailedToCreateRouteException exception happens in Camel while creating a route but not able to create it because of some dependency missing for configuring the SMTP camel route for sending an email.

Camel SMTP Route Configuration

Here is Camel Route Definition for sending email.


String recipients = "&to=camel123@riders.org,easy123@riders.org&cc=me@you.org&bcc=someone@somewhere.org";
        from("direct:a").to("smtps://smtp.gmail.com:465?username=job4saurabh@gmail.com&password=XYZ@123" + recipients); 

 

Exception StackTrace

This exception happen at runtime because of required dependency missing.


2020-04-08 13:47:00 - Error starting CamelContext (camel-1) due to exception thrown: Failed to create route route1: Route(route1)[From[sendEmail] -> [To[smtps://smtp.gmail.com:... because of No endpoint could be found for: sendEmail, please check your classpath contains the needed Camel component jar.
org.apache.camel.FailedToCreateRouteException: Failed to create route route1: Route(route1)[From[sendEmail] -> [To[smtps://smtp.gmail.com:... because of No endpoint could be found for: sendEmail, please check your classpath contains the needed Camel component jar.
    at org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:118)
    at org.apache.camel.impl.DefaultModel.start(DefaultModel.java:356)
    at org.apache.camel.impl.DefaultModel.startRoute(DefaultModel.java:330)
    at org.apache.camel.impl.DefaultModel.startRouteDefinitions(DefaultModel.java:323)
    at org.apache.camel.impl.DefaultModel.startRouteDefinitions(DefaultModel.java:302)
    at org.apache.camel.impl.AbstractModelCamelContext.startRouteDefinitions(AbstractModelCamelContext.java:326)
    at org.apache.camel.impl.engine.AbstractCamelContext.doStartCamel(AbstractCamelContext.java:2679)
    at org.apache.camel.impl.engine.AbstractCamelContext.lambda$doStart$2(AbstractCamelContext.java:2527)
    at org.apache.camel.impl.engine.AbstractCamelContext.doWithDefinedClassLoader(AbstractCamelContext.java:2544)
    at org.apache.camel.impl.engine.AbstractCamelContext.doStart(AbstractCamelContext.java:2525)
    at org.apache.camel.spring.boot.SpringBootCamelContext.doStart(SpringBootCamelContext.java:43)
Caused by: org.apache.camel.NoSuchEndpointException: No endpoint could be found for: sendEmail, please check your classpath contains the needed Camel component jar.
    at org.apache.camel.support.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:59)
    at org.apache.camel.impl.engine.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:123)
    at org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:367)
    at org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:112)
    ... 57 common frames omitted

Exception Reason

As Camel support multiple type of routing and it required dependcies for use it. Here we are using SMTP routing to send email on came of defined routing but it required to add camel dependency for SMTP email in pom.xml.

Solution

As exception stack trace clearly explained, it required missing camel component jar. In case of SMTP you need to add below jar for sending Email through camel SMTP route.


           <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-core</artifactId>
            <version>${camel.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-mail</artifactId>
            <version>${camel.version}</version>
        </dependency>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s