[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

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