While running the camel route why the error occurs if email address have character '&' ?
Environment
- Red Hat JBoss Fuse
- 6.1.0
Issue
- Camel is throwing error while creating route with email address having special characters like '&'. See the following error more information
17:56:31,804 | ERROR | l Console Thread | BlueprintCamelContext | 151 - org.apache.camel.camel-blueprint - 2.12.0.redhat-610379 | Error occurred during starting Camel: CamelContext(camel-9) due Failed to create route route9 at: >>> To[smtp://test.example.com:25?To=user&123@gexample.com&From=testuser@gexample.com] <<< in route: Route(route9)[[From[timer://foo?delay=2s&repeatCount=1]] -> ... because of Failed to resolve endpoint: smtp://test.example.com:25?123%40gexample.com=&From=testuser%40gexample.com&To=user due to: Failed to resolve endpoint: smtp://test.example.com:25?123%40gexample.com=&From=testuser%40gexample.com&To=user due to: There are 1 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=[{123@gexample.com=}]
org.apache.camel.FailedToCreateRouteException: Failed to create route route9 at: >>> To[smtp://test.example.com:25?To=user&123@gexample.com&From=testuser@gexample.com] <<< in route: Route(route9)[[From[timer://foo?delay=2s&repeatCount=1]] -> ... because of Failed to resolve endpoint: smtp://test.example.com:25?123%40gexample.com=&From=testuser%40gexample.com&To=user due to: Failed to resolve endpoint: smtp://test.example.com:25?123%40gexample.com=&From=testuser%40gexample.com&To=user due to: There are 1 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=[{123@gexample.com=}]
16:14:18,722 INFO [57482-restart-job] (Camel (camel-2) thread #15 - JmsConsumer[service.routing.jms.broker.dest.process.job]) org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: smtp://test.example.com:25?123%40gexample.com=&From=testuser%40gexample.com&&mail.smtp.auth=false&mail.smtp.starttls.enable=true&subject=TestMail&To=user due to: There are 1 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=[{123@gexample.com=}]
at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:531)
at org.apache.camel.impl.DefaultProducerTemplate.resolveMandatoryEndpoint(DefaultProducerTemplate.java:449)
at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:143)
at email.EmailBean.send(EmailBean.java:138)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:407)
at org.apache.camel.component.bean.MethodInfo$1.doProceed(MethodInfo.java:278)
at org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:251)
at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:166)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:105)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:279)
at org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:56)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:166)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
at org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:111)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)
at org.apache.camel.spring.spi.TransactionErrorHandler.processByErrorHandler(TransactionErrorHandler.java:218)
at org.apache.camel.spring.spi.TransactionErrorHandler$1.doInTransactionWithoutResult(TransactionErrorHandler.java:181)
at org.springframework.transaction.support.TransactionCallbackWithoutResult.doInTransaction(TransactionCallbackWithoutResult.java:34)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
at org.apache.camel.spring.spi.TransactionErrorHandler.doInTransactionTemplate(TransactionErrorHandler.java:174)
at org.apache.camel.spring.spi.TransactionErrorHandler.processInTransaction(TransactionErrorHandler.java:134)
at org.apache.camel.spring.spi.TransactionErrorHandler.process(TransactionErrorHandler.java:103)
at org.apache.camel.spring.spi.TransactionErrorHandler.process(TransactionErrorHandler.java:112)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:51)
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
at org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:111)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:105)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:87)
at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:103)
at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:562)
at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:500)
at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:468)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:325)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:243)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1101)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1093)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:990)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: smtp://test@testsmtp.test.com:25?something%40test.com=&from=test%40chaattest01&mail.smtp.auth=false&mail.smtp.starttls.enable=true&subject=Test+Mail.&to=totestuser123%40test.com%2 due to: There are 1 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=[{something@test.com=}]
at org.apache.camel.impl.DefaultComponent.validateParameters(DefaultComponent.java:192)
at org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:137)
at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:511)
... 62 more
Resolution
- From apache camel 2.11 onwards there is a new feature added as http://camel.apache.org/how-do-i-configure-endpoints.html. When configuring endpoint options using URI syntax, then the values is by default URI encoded. This can be a problem if user want to configure passwords and just use the value as is without any encoding. For example user may have a plus sign in the password, which would be decimal encoded by default. So from Camel 2.11 onwards we made this easier as users can denote a parameter value to be raw using the following syntax
"RAW(value)"
. example the value starts with"RAW( and then ends with the parenthesis )"
uri="smtp://test.example.com:25?To=RAW(user&123@gexample.com)&From=jsenshar@gexample.com"
- Notice in the above case To address is supposed to be
"user&123@gexample.com"
so while writing it inside the URI users need to replace it with"RAW(user&123@gexample.com)"
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments