Category Archives: apache camel

[Solved] org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: smtps://smtp.gmail.com:465?XYZ due to: There are 2 parameters that couldn’t be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint.


org.apache.camel.ResolveEndpointFailedException throws when an endpoint is not resolved by URI. It can happen because of formatting, escaping characters of the keyword are not used properly.

Camel Route Definition for SMTP Email

Here is the configured Camel route definition for SMTP email. Which is written as from one Gmail account to another email like to, CC and BCC.


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

As the exception cause described it’s because of unknown parameters CC and BCC. As for Camel Route Definition recognized all keywords in small letters.

 
org.apache.camel.FailedToCreateRouteException: Failed to create route route1 at: >>> To[smtps://smtp.gmail.com:465?username=job4saurabh@gmail.com&password=XYZ@123&to=camel123@riders.org,easy123@riders.org&CC=me@you.org&BCC=someone@somewhere.org] <<< in route: Route(route1)[From[direct:a] -> [To[smtps://smtp.gmail.com:x... because of Failed to resolve endpoint: smtps://smtp.gmail.com:465?BCC=someone%40somewhere.org&CC=me%40you.org&password=xxxxxx&to=camel123%40riders.org%2Ceasy123%40riders.org&username=job4saurabh%40gmail.com due to: Failed to resolve endpoint: smtps://smtp.gmail.com:465?BCC=someone%40somewhere.org&CC=me%40you.org&password=xxxxxx&to=camel123%40riders.org%2Ceasy123%40riders.org&username=job4saurabh%40gmail.com due to: There are 2 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{BCC=someone@somewhere.org, CC=me@you.org}]
    at org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:390)
    at org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:112)
    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)
    
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: smtps://smtp.gmail.com:465?BCC=someone%40somewhere.org&CC=me%40you.org&password=xxxxxx&to=camel123%40riders.org%2Ceasy123%40riders.org&username=job4saurabh%40gmail.com due to: Failed to resolve endpoint: smtps://smtp.gmail.com:465?BCC=someone%40somewhere.org&CC=me%40you.org&password=xxxxxx&to=camel123%40riders.org%2Ceasy123%40riders.org&username=job4saurabh%40gmail.com due to: There are 2 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{BCC=someone@somewhere.org, CC=me@you.org}]
    at org.apache.camel.impl.engine.AbstractCamelContext.getEndpoint(AbstractCamelContext.java:828)
    at org.apache.camel.impl.engine.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:130)
    at org.apache.camel.reifier.SendReifier.resolveEndpoint(SendReifier.java:42)
    at org.apache.camel.reifier.SendReifier.createProcessor(SendReifier.java:35)
    at org.apache.camel.reifier.ProcessorReifier.makeProcessor(ProcessorReifier.java:787)
    at org.apache.camel.reifier.ProcessorReifier.addRoutes(ProcessorReifier.java:513)
    at org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:388)
    ... 35 common frames omitted
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: smtps://smtp.gmail.com:465?BCC=someone%40somewhere.org&CC=me%40you.org&password=xxxxxx&to=camel123%40riders.org%2Ceasy123%40riders.org&username=job4saurabh%40gmail.com due to: There are 2 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{BCC=someone@somewhere.org, CC=me@you.org}]
    at org.apache.camel.support.DefaultComponent.validateParameters(DefaultComponent.java:358)
    at org.apache.camel.support.DefaultComponent.createEndpoint(DefaultComponent.java:261)
    at org.apache.camel.impl.engine.AbstractCamelContext.getEndpoint(AbstractCamelContext.java:780)
    ... 41 common frames omitted

Exception Reason

Apache Camel through this exception because of endpoint for URI is not resolved because of case-sensitive keywords. As here we are using BCC and CC as in capital letters while Apache camel allowed all keywords in small letters only.

Solution

Use keyword BCC and CC in small letters as defined in below camel route definition.


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);

You can check all list of keywords for apache camel routes for SMTP in below list:
https://people.apache.org/~dkulp/camel/mail.html

Reference

https://www.javadoc.io/doc/org.apache.camel/camel-core/2.15.0/org/apache/camel/ResolveEndpointFailedException.html

[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>