One Star

cDynamicRouter and different endpoints

Hi all, 
I have the route (attached bellow). 
I have to dynamically redirect the messages depending on the Http verb (I tried to do it using another approch but it was an epic fail Smiley Tongue
used the link
The problem is that only the "DELETE" method is working, and yet I have the error:  

 :1:1: Fin prématurée du fichier.
: org.apache.camel.processor.DefaultErrorHandler - Failed delivery for (MessageId: ID-LFR204094-55535-1439324535115-0-3 on ExchangeId: ID-LFR204094-55535-1439324535115-0-1). Exhausted after delivery attempt: 1 caught: org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange]


while with the GET or POST methods all I have is this error:


 :1:1: Contenu non autorisé dans le prologue.
: org.apache.camel.processor.DefaultErrorHandler - Failed delivery for (MessageId: ID-LFR204094-56301-1439325581670-0-3 on ExchangeId: ID-LFR204094-56301-1439325581670-0-1). Exhausted after delivery attempt: 1 caught: org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange]


I bridged the URLs:

"http://localhost:8081/webMavenChouette?bridgeEndpoint=true&throwExceptionOnFailure=false"


please find attached the snapshots of the route and the bean:

Thank you for your time 
-Regards

  • ESB
40 REPLIES
One Star

Re: cDynamicRouter and different endpoints

I addedd a cErrorHandler: 

Here's what I got as logs 
: org.eclipse.jetty.server.AbstractConnector - Started SelectChannelConnector@localhost:8084
: org.apache.camel.spring.SpringCamelContext - Route: Base_cHttp_1 started and consuming from: Endpoint
: org.apache.camel.spring.SpringCamelContext - Route: POST_cMessagingEndpoint_1 started and consuming from: Endpoint
: org.apache.camel.spring.SpringCamelContext - Route: GET_cMessagingEndpoint_2 started and consuming from: Endpoint
: org.apache.camel.spring.SpringCamelContext - Route: DELETE_cMessagingEndpoint_3 started and consuming from: Endpoint
: org.apache.camel.spring.SpringCamelContext - Total 4 routes, of which 4 is started.
: org.apache.camel.spring.SpringCamelContext - Apache Camel 2.15.2 (CamelContext: RouteChouetteSplit-ctx) started in 1.790 seconds
: chouetteRoute.cLog_7 - GET CLIENT
: org.apache.commons.httpclient.HttpMethodDirector - I/O exception (java.net.ConnectException) caught when processing request: Connection refused: connect
: org.apache.commons.httpclient.HttpMethodDirector - Retrying request
: org.apache.commons.httpclient.HttpMethodDirector - I/O exception (java.net.ConnectException) caught when processing request: Connection refused: connect
: org.apache.commons.httpclient.HttpMethodDirector - Retrying request
: org.apache.commons.httpclient.HttpMethodDirector - I/O exception (java.net.ConnectException) caught when processing request: Connection refused: connect
: org.apache.commons.httpclient.HttpMethodDirector - Retrying request
: org.slf4j.Logger - Failed delivery for (MessageId: ID-LFR204094-53626-1439369472006-0-2 on ExchangeId: ID-LFR204094-53626-1439369472006-0-1). Exhausted after delivery attempt: 1 caught: java.net.ConnectException: Connection refused: connect
Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId ProcessorId Processor Elapsed (ms)

]

]

Exchange
---------------------------------------------------------------------------------------------------------------------------------------
Exchange
]
Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.(Unknown Source)
at java.net.Socket.(Unknown Source)
at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:80)
at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:122)
at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
at org.apache.camel.component.http.HttpProducer.executeMethod(HttpProducer.java:244)
at org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:144)
at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:129)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:91)
at routines.system.CamelStat$1$1.process(CamelStat.java:56)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:91)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:448)
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.RoutingSlip$2.doInAsyncProducer(RoutingSlip.java:301)
at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:304)
at org.apache.camel.processor.RoutingSlip.processExchange(RoutingSlip.java:294)
at org.apache.camel.processor.RoutingSlip.doRoutingSlip(RoutingSlip.java:215)
at org.apache.camel.processor.RoutingSlip.process(RoutingSlip.java:146)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:91)
at routines.system.CamelStat$1$1.process(CamelStat.java:56)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:91)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:448)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
at org.apache.camel.component.jetty.CamelContinuationServlet.service(CamelContinuationServlet.java:162)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:686)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1494)
at org.eclipse.jetty.servlets.MultiPartFilter.doFilter(MultiPartFilter.java:136)
at org.apache.camel.component.jetty.CamelFilterWrapper.doFilter(CamelFilterWrapper.java:43)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1465)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:499)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:428)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:370)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:949)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1011)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:668)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Unknown Source)

-Regards
One Star

Re: cDynamicRouter and different endpoints

well, as it's said in the docs, the cMessagingEndpoint allows two applications to communicate by either sending or receiving messages, one endpoint can not do both.  so I replaced it with a cHttp component, as a server (please find the picture attached). 
The route worked one time as expected with no errors, after a restart of my computer, it gives me this errors: 
Démarrage du job testDynamicRouter a 15:12 13/08/2015.
: org.apache.camel.main.MainSupport - Apache Camel 2.15.2 starting
: org.springframework.context.support.ClassPathXmlApplicationContext - Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@38d760bb: startup date ; root of context hierarchy
: org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource
: org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@57fcbecc: defining beans ; root of factory hierarchy
connecting to socket on port 3421
connected
: org.apache.camel.spring.SpringCamelContext - Apache Camel 2.15.2 (CamelContext: testDynamicRouter-ctx) is starting
: org.apache.camel.management.ManagedManagementStrategy - JMX is enabled
: org.apache.camel.impl.converter.DefaultTypeConverter - Loaded 193 type converters
: org.apache.camel.spring.SpringCamelContext - AllowUseOriginalMessage is enabled. If access to the original message is not needed, then its recommended to turn this option off as it may improve performance.
: org.apache.camel.spring.SpringCamelContext - StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
: org.apache.camel.component.jetty.JettyHttpComponent - Jetty JMX Extensions is enabled
: org.apache.camel.component.jetty.JettyHttpComponent - Using default Jetty continuation timeout for: Endpoint
: org.eclipse.jetty.server.Server - jetty-8.1.12.v20130726
: org.eclipse.jetty.server.AbstractConnector - Started SelectChannelConnector@0.0.0.0:80
: org.eclipse.jetty.server.handler.ContextHandler - stopped o.e.j.s.ServletContextHandler{/,null}
: org.apache.camel.spring.SpringCamelContext - Apache Camel 2.15.2 (CamelContext: testDynamicRouter-ctx) is shutting down
null
java.lang.NullPointerException
at org.apache.camel.component.http.HttpEndpoint.getPath(HttpEndpoint.java:241)
at org.apache.camel.component.jetty.JettyHttpComponent.enableMultipartFilter(JettyHttpComponent.java:432)
at org.apache.camel.component.jetty.JettyHttpComponent.connect(JettyHttpComponent.java:356)
at org.apache.camel.component.http.HttpEndpoint.connect(HttpEndpoint.java:178)
at org.apache.camel.component.http.HttpConsumer.doStart(HttpConsumer.java:53)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.impl.DefaultCamelContext.startService(DefaultCamelContext.java:2869)
at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRouteConsumers(DefaultCamelContext.java:3163)
at org.apache.camel.impl.DefaultCamelContext.doStartRouteConsumers(DefaultCamelContext.java:3099)
at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:3029)
at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:2797)
: org.apache.camel.spring.SpringCamelContext - Apache Camel 2.15.2 (CamelContext: testDynamicRouter-ctx) uptime 1.010 seconds
: org.apache.camel.spring.SpringCamelContext - Apache Camel 2.15.2 (CamelContext: testDynamicRouter-ctx) is shutdown in 0.004 seconds
: org.apache.camel.main.MainSupport - Apache Camel 2.15.2 stopping
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:2653)
at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:167)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2467)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2463)
at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2486)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2463)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2432)
at org.apache.camel.main.Main.doStart(Main.java:124)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.main.MainSupport.run(MainSupport.java:150)
at restclient.testdynamicrouter_0_1.testDynamicRouter.run(testDynamicRouter.java:240)
at restclient.testdynamicrouter_0_1.testDynamicRouter.runJobInTOS(testDynamicRouter.java:326)
at restclient.testdynamicrouter_0_1.testDynamicRouter.main(testDynamicRouter.java:287)

and if  put "direct://GET" (I add // ) to the URI in the cHttp component, the error become: 
: org.apache.camel.main.MainSupport - Apache Camel 2.15.2 starting
: org.springframework.context.support.ClassPathXmlApplicationContext - Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@440fb224: startup date ; root of context hierarchy
: org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource
: org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@57fcbecc: defining beans ; root of factory hierarchy
connecting to socket on port 3846
connected
: org.apache.camel.spring.SpringCamelContext - Apache Camel 2.15.2 (CamelContext: testDynamicRouter-ctx) is starting
: org.apache.camel.management.ManagedManagementStrategy - JMX is enabled
: org.apache.camel.impl.converter.DefaultTypeConverter - Loaded 193 type converters
: org.apache.camel.spring.SpringCamelContext - AllowUseOriginalMessage is enabled. If access to the original message is not needed, then its recommended to turn this option off as it may improve performance.
: org.apache.camel.spring.SpringCamelContext - StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
: org.apache.camel.component.jetty.JettyHttpComponent - Jetty JMX Extensions is enabled
: org.apache.camel.component.jetty.JettyHttpComponent - Using default Jetty continuation timeout for: Endpoint
: org.eclipse.jetty.server.Server - jetty-8.1.12.v20130726
: org.eclipse.jetty.util.component.AbstractLifeCycle - FAILED SelectChannelConnector@GET:80: java.net.SocketException: Unresolved address
java.net.SocketException: Unresolved address
at sun.nio.ch.Net.translateToSocketException(Unknown Source)
at sun.nio.ch.Net.translateException(Unknown Source)
at sun.nio.ch.Net.translateException(Unknown Source)
at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
at org.eclipse.jetty.server.nio.SelectChannelConnector.open(SelectChannelConnector.java:187)
at org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:316)
at org.eclipse.jetty.server.nio.SelectChannelConnector.doStart(SelectChannelConnector.java:265)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.eclipse.jetty.server.Server.doStart(Server.java:293)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.apache.camel.component.jetty.JettyHttpComponent.connect(JettyHttpComponent.java:335)
at org.apache.camel.component.http.HttpEndpoint.connect(HttpEndpoint.java:178)
at org.apache.camel.component.http.HttpConsumer.doStart(HttpConsumer.java:53)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.impl.DefaultCamelContext.startService(DefaultCamelContext.java:2869)
at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRouteConsumers(DefaultCamelContext.java:3163)
at org.apache.camel.impl.DefaultCamelContext.doStartRouteConsumers(DefaultCamelContext.java:3099)
at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:3029)
at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:2797)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:2653)
at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:167)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2467)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2463)
at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2486)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2463)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2432)
at org.apache.camel.main.Main.doStart(Main.java:124)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.main.MainSupport.run(MainSupport.java:150)
at restclient.testdynamicrouter_0_1.testDynamicRouter.run(testDynamicRouter.java:240)
at restclient.testdynamicrouter_0_1.testDynamicRouter.runJobInTOS(testDynamicRouter.java:326)
at restclient.testdynamicrouter_0_1.testDynamicRouter.main(testDynamicRouter.java:287)
Caused by: java.nio.channels.UnresolvedAddressException
at sun.nio.ch.Net.checkAddress(Unknown Source)
at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
... 30 more
: org.eclipse.jetty.util.component.AbstractLifeCycle - FAILED org.eclipse.jetty.server.Server@6e5c0621: java.net.SocketException: Unresolved address
java.net.SocketException: Unresolved address
at sun.nio.ch.Net.translateToSocketException(Unknown Source)
at sun.nio.ch.Net.translateException(Unknown Source)
at sun.nio.ch.Net.translateException(Unknown Source)
at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
at org.eclipse.jetty.server.nio.SelectChannelConnector.open(SelectChannelConnector.java:187)
at org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:316)
at org.eclipse.jetty.server.nio.SelectChannelConnector.doStart(SelectChannelConnector.java:265)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.eclipse.jetty.server.Server.doStart(Server.java:293)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.apache.camel.component.jetty.JettyHttpComponent.connect(JettyHttpComponent.java:335)
at org.apache.camel.component.http.HttpEndpoint.connect(HttpEndpoint.java:178)
at org.apache.camel.component.http.HttpConsumer.doStart(HttpConsumer.java:53)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.impl.DefaultCamelContext.startService(DefaultCamelContext.java:2869)
at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRouteConsumers(DefaultCamelContext.java:3163)
at org.apache.camel.impl.DefaultCamelContext.doStartRouteConsumers(DefaultCamelContext.java:3099)
at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:3029)
at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:2797)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:2653)
at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:167)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2467)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2463)
at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2486)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2463)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2432)
at org.apache.camel.main.Main.doStart(Main.java:124)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.main.MainSupport.run(MainSupport.java:150)
at restclient.testdynamicrouter_0_1.testDynamicRouter.run(testDynamicRouter.java:240)
at restclient.testdynamicrouter_0_1.testDynamicRouter.runJobInTOS(testDynamicRouter.java:326)
at restclient.testdynamicrouter_0_1.testDynamicRouter.main(testDynamicRouter.java:287)
Caused by: java.nio.channels.UnresolvedAddressException
at sun.nio.ch.Net.checkAddress(Unknown Source)
at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
... 30 more
: org.apache.camel.spring.SpringCamelContext - Apache Camel 2.15.2 (CamelContext: testDynamicRouter-ctx) is shutting down
Unresolved address
java.net.SocketException: Unresolved address
at sun.nio.ch.Net.translateToSocketException(Unknown Source)
at sun.nio.ch.Net.translateException(Unknown Source)
at sun.nio.ch.Net.translateException(Unknown Source)
at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
at org.eclipse.jetty.server.nio.SelectChannelConnector.open(SelectChannelConnector.java:187)
at org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:316)
at org.eclipse.jetty.server.nio.SelectChannelConnector.doStart(SelectChannelConnector.java:265)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.eclipse.jetty.server.Server.doStart(Server.java:293)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.apache.camel.component.jetty.JettyHttpComponent.connect(JettyHttpComponent.java:335)
at org.apache.camel.component.http.HttpEndpoint.connect(HttpEndpoint.java:178)
at org.apache.camel.component.http.HttpConsumer.doStart(HttpConsumer.java:53)
: org.apache.camel.spring.SpringCamelContext - Apache Camel 2.15.2 (CamelContext: testDynamicRouter-ctx) uptime 3.206 seconds
: org.apache.camel.spring.SpringCamelContext - Apache Camel 2.15.2 (CamelContext: testDynamicRouter-ctx) is shutdown in 0.007 seconds
: org.apache.camel.main.MainSupport - Apache Camel 2.15.2 stopping
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.impl.DefaultCamelContext.startService(DefaultCamelContext.java:2869)
at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRouteConsumers(DefaultCamelContext.java:3163)
at org.apache.camel.impl.DefaultCamelContext.doStartRouteConsumers(DefaultCamelContext.java:3099)
at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:3029)
at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:2797)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:2653)
at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:167)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2467)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2463)
at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2486)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2463)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2432)
at org.apache.camel.main.Main.doStart(Main.java:124)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.main.MainSupport.run(MainSupport.java:150)
at restclient.testdynamicrouter_0_1.testDynamicRouter.run(testDynamicRouter.java:240)
at restclient.testdynamicrouter_0_1.testDynamicRouter.runJobInTOS(testDynamicRouter.java:326)
at restclient.testdynamicrouter_0_1.testDynamicRouter.main(testDynamicRouter.java:287)
Caused by: java.nio.channels.UnresolvedAddressException
at sun.nio.ch.Net.checkAddress(Unknown Source)
at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
... 30 more


may I have a hint about what can be the problem??                                                                                 
Thank you 
Eleven Stars

Re: cDynamicRouter and different endpoints

What is the difference between the DELETE, GET and POST cHttp components? How are each of them configured? What type of data is sent? Are they set up as Client rather than Server?
Rilhia Solutions
One Star

Re: cDynamicRouter and different endpoints

Thank you for your answer
the cHttp DELETE , POST  and GET are all set up as "client", they all have the same URI:
URI="http://localhost:8081/webMavenChouette?bridgeEndpoint=true&throwExceptionOnFailure=false"

calling a REST web service. 
The difference is the configuration, the one called "DELETE" uses the methode "DELETE", the one called "POST" uses the methode "POST", the one called "GET" uses the methode "GET".  They will be used to differenciate the processing according to the HTTP verb used
the data sent is json objects. 
-Regards
Eleven Stars

Re: cDynamicRouter and different endpoints

Have you tested each of the http verbs with the service you are sending them to without this process? It could be a problem with that service.
Rilhia Solutions
One Star

Re: cDynamicRouter and different endpoints

Actually I've already tested the service itself using a route : 
chttp (server) -> chttp(client) -> cMessageRouter ->2 when branches to test the Exchange.HTTP_RESPONSE_CODE ->cLogs
and it's working just fine with the 3 http verbs
The problem occurs when I introduce the cDynamicRouter. to do the if/else conditions, I used a bean, using the cBeanRegister" component,  which redirects the message 
public String setURI(Document document,@Header(Exchange.SLIP_ENDPOINT) String previous, 
@Header(Exchange.HTTP_METHOD) String httpVerb) {

if (previous != null) {
return null;
}

return "direct:" + httpVerb;

it returns a "direct:GET" (if the request was a GET) that is put in the "GET_server": a chttp server component ; 
please reconsider the snapshots, I renamed the chttp component depending on their configuration. 
Eleven Stars

Re: cDynamicRouter and different endpoints

Where is the service you are calling running? Is it running in the Studio or in the Karaf? Do you have more than one service; 1 for each verb?
Also, can you add the following code to your routine?
public String setURI(Document document,@Header(Exchange.SLIP_ENDPOINT) String previous, 
@Header(Exchange.HTTP_METHOD) String httpVerb) {

if (previous != null) {
return null;
}

System.out.out.println("direct:"+httpVerb); //<--- This code to see what is produced
return "direct:" + httpVerb;
}
Rilhia Solutions
One Star

Re: cDynamicRouter and different endpoints

my service is running in eclipse, it's a spring mvc application, with Rest controllers
and the  System.out.out.println("direct:"+httpVerb); prints the http verb I'm using in the request in the Rest Client DHC
==> if it's a GET request then the code prints "direct:GET"
Eleven Stars

Re: cDynamicRouter and different endpoints

I *think* I might have the answer, but I can't test it here. Looking at your error messages it looks like the service is throwing errors because it is expecting a String but is receiving the body as an instance of java.io.InputStream. To work around this, try putting cProcessor components before your POST_client, GET_client and DELETE_client components. In each of the cProcessor components, put the following code.....
String jsonString = exchange.getIn().getBody(String.class);
exchange.getIn().setBody(jsonString);

What you are doing here is forcing the body to be converted to a String (from an instance of java.io.InputStream) and then putting it back into the "in" message as a String.
This won't necessarily get it to work perfectly, but you should see it get further after this.
Let me know if it works.
Rilhia Solutions
One Star

Re: cDynamicRouter and different endpoints

I tested your hint but I still have the exact same error, but  I don't think your guess is right because even when I keep just the GET_server, I still have the same error message
Eleven Stars

Re: cDynamicRouter and different endpoints

You cannot have the cHttp components as POST_Server, GET_Server and DELETE_SERVER. These should be cMessagingEndpoint components. cMessagingEndpoint components allow you to use the direct endpoint. They are generic endpoints that allow you to use any of the Camel Components. The cHttp components are for producing or consuming service calls. Although you are working with services here, you are actually using the Camel direct component to pass the messages from the cDynamicRouter. Therefore you must use the cMessagingEndpoint.
Rilhia Solutions
One Star

Re: cDynamicRouter and different endpoints

I've already used the cMessagingEndpoint (please see the first message) but this component  allows two applications to communicate by either sending or receiving messages, one endpoint can not do both, so I cannot have "an answer" from the service web, and *I think* that's why only the DELETE method worked for me 
I jest retested with a cMessagingEndpoint component and a GET request: 
: org.apache.camel.main.MainSupport - Apache Camel 2.15.2 starting
: org.springframework.context.support.ClassPathXmlApplicationContext - Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@7bc0bd17: startup date ; root of context hierarchy
: org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource
: org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@2426e26f: defining beans ; root of factory hierarchy
connecting to socket on port 3864
connected
: org.apache.camel.spring.SpringCamelContext - Apache Camel 2.15.2 (CamelContext: cDynamic-ctx) is starting
: org.apache.camel.management.ManagedManagementStrategy - JMX is enabled
: org.apache.camel.impl.converter.DefaultTypeConverter - Loaded 193 type converters
: org.apache.camel.spring.SpringCamelContext - AllowUseOriginalMessage is enabled. If access to the original message is not needed, then its recommended to turn this option off as it may improve performance.
: org.apache.camel.spring.SpringCamelContext - StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
: org.apache.camel.component.jetty.JettyHttpComponent - You use localhost interface! It means that no external connections will be available. Don't you want to use 0.0.0.0 instead (all network interfaces)? Endpoint
: org.apache.camel.component.jetty.JettyHttpComponent - Using default Jetty continuation timeout for: Endpoint
: org.eclipse.jetty.server.Server - jetty-8.1.12.v20130726
: org.eclipse.jetty.server.AbstractConnector - Started SelectChannelConnector@localhost:8086
: org.apache.camel.spring.SpringCamelContext - Route: Base_cHttp_1 started and consuming from: Endpoint
: org.apache.camel.spring.SpringCamelContext - Route: cMessagingEndpoint_1 started and consuming from: Endpoint
: org.apache.camel.spring.SpringCamelContext - Total 2 routes, of which 2 is started.
: org.apache.camel.spring.SpringCamelContext - Apache Camel 2.15.2 (CamelContext: cDynamic-ctx) started in 1.074 seconds
: cDynamicRouter.cLog_1 - Exchange]
:1:1: Contenu non autorisé dans le prologue.
: org.slf4j.Logger - Failed delivery for (MessageId: ID-LFR204094-51171-1439556017634-0-3 on ExchangeId: ID-LFR204094-51171-1439556017634-0-1). Exhausted after delivery attempt: 1 caught: org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange]
Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId              ProcessorId          Processor                                                                        Elapsed (ms)

                                        ]

                                                   ]

choice

Exchange
---------------------------------------------------------------------------------------------------------------------------------------
Exchange
]
Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange]
at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1635)
at org.apache.camel.builder.ExpressionBuilder$42.evaluate(ExpressionBuilder.java:1039)
at org.apache.camel.support.ExpressionAdapter.evaluate(ExpressionAdapter.java:36)
at org.apache.camel.component.bean.MethodInfo$2.evaluateParameterBinding(MethodInfo.java:592)
at org.apache.camel.component.bean.MethodInfo$2.evaluate(MethodInfo.java:484)
at org.apache.camel.component.bean.MethodInfo.createMethodInvocation(MethodInfo.java:240)
at org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:283)
at org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:183)
at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:153)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:68)
at org.apache.camel.language.bean.BeanExpression$InvokeProcessor.process(BeanExpression.java:194)
at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:123)
at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:132)
at org.apache.camel.processor.DynamicRouter$DynamicRoutingSlipIterator.hasNext(DynamicRouter.java:67)
at org.apache.camel.processor.RoutingSlip.doRoutingSlip(RoutingSlip.java:200)
at org.apache.camel.processor.RoutingSlip.process(RoutingSlip.java:146)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:91)
at routines.system.CamelStat$1$1.process(CamelStat.java:56)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:91)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:448)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
at org.apache.camel.component.jetty.CamelContinuationServlet.service(CamelContinuationServlet.java:162)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:686)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1494)
at org.eclipse.jetty.servlets.MultiPartFilter.doFilter(MultiPartFilter.java:136)
at org.apache.camel.component.jetty.CamelFilterWrapper.doFilter(CamelFilterWrapper.java:43)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1465)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:499)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:428)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:370)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:949)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1011)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:668)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.camel.InvalidPayloadException: No body available of type: org.w3c.dom.Document but has value: org.apache.camel.converter.stream.CachedOutputStream$WrappedInputStream@6c15234e of type: org.apache.camel.converter.stream.CachedOutputStream.WrappedInputStream on: Message: . Caused by: Error during type conversion from type: java.lang.String to the required type: org.w3c.dom.Document with value due org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Contenu non autorisé dans le prologue.. Exchange]. Caused by: due org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Contenu non autorisé dans le prologue.]
at org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:101)
at org.apache.camel.builder.ExpressionBuilder$42.evaluate(ExpressionBuilder.java:1037)
... 47 more
Caused by: org.apache.camel.TypeConversionException: Error during type conversion from type: java.lang.String to the required type: org.w3c.dom.Document with value due org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Contenu non autorisé dans le prologue.
at org.apache.camel.impl.converter.BaseTypeConverterRegistry.createTypeConversionException(BaseTypeConverterRegistry.java:571)
at org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:169)
at org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:99)
... 48 more
Caused by: org.apache.camel.RuntimeCamelException: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Contenu non autorisé dans le prologue.
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1619)
at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1224)
at org.apache.camel.impl.converter.InstanceMethodTypeConverter.convertTo(InstanceMethodTypeConverter.java:78)
at org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:285)
at org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:160)
... 49 more
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Contenu non autorisé dans le prologue.
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
at org.apache.camel.converter.jaxp.XmlConverter.toDOMDocument(XmlConverter.java:853)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1220)
... 52 more


One Star

Re: cDynamicRouter and different endpoints

I also tried a "sipmler" way, using a cMessagingRouter component: 

However, the route just behaves weirdly,it  does not work depending on the corresponding logic to the graph.for example: the branch "when2" is called only when the two conditions "when4" and "when5" are false (dspite the fact that in my Rest Client, the http verb is "DELETE".
When I looked into the code, it appers that it's a little bit *messy*, it's not clear which ".when(...)" is related to which ".choice()": 
public void configure() throws java.lang.Exception {
from(uriMap.get("cHttp_3"))
.routeId("Base_cHttp_3")
.choice()
.id("cMessageRouter_1")
.when()
.simple("${header." + org.apache.camel.Exchange.HTTP_METHOD
+ "} == 'GET'")
.setHeader("CamelHttpMethod", constant("GET"))
.to(uriMap.get("cHttp_4"))
.id("cHttp_4")
.choice()
.id("cMessageRouter_2")
.when()
.simple("${header."
+ org.apache.camel.Exchange.HTTP_RESPONSE_CODE
+ "} == 200 ")
.log(org.apache.camel.LoggingLevel.INFO,
"chouetteRoute.cLog_1", "good")
.id("cLog_2")
.when()
.simple("${header."
+ org.apache.camel.Exchange.HTTP_RESPONSE_CODE
+ "} == 200 ")
.log(org.apache.camel.LoggingLevel.ERROR,
"chouetteRoute.cLog_1", "eRREUR")
.id("cLog_9")
.when()
.simple("${header." + org.apache.camel.Exchange.HTTP_METHOD
+ "} == 'POST'")
.setHeader("CamelHttpMethod", constant("POST"))
.setHeader("Content-Type", constant("application/json"))
.to(uriMap.get("cHttp_7"))
.id("cHttp_7")
.choice()
.id("cMessageRouter_4")
.when()
.simple("${header."
+ org.apache.camel.Exchange.HTTP_RESPONSE_CODE
+ "} == 200 ")
.log(org.apache.camel.LoggingLevel.INFO,
"chouetteRoute.cLog_1", "good")
.id("cLog_5")
.when()
.simple("${header."
+ org.apache.camel.Exchange.HTTP_RESPONSE_CODE
+ "} == 404 ")
.log(org.apache.camel.LoggingLevel.ERROR,
"chouetteRoute.cLog_1", "eRREUR")
.id("cLog_6")
.when()
.simple("${header." + org.apache.camel.Exchange.HTTP_METHOD
+ "} == 'DELETE'")
.setHeader("CamelHttpMethod", constant("DELETE"))
.to(uriMap.get("cHttp_1"))
.id("cHttp_1")
.choice()
.id("cMessageRouter_3")
.when()
.simple("${header."
+ org.apache.camel.Exchange.HTTP_RESPONSE_CODE
+ "} == 200 ")
.log(org.apache.camel.LoggingLevel.INFO,
"chouetteRoute.cLog_1", "good")
.id("cLog_3")
.when()
.simple("${header."
+ org.apache.camel.Exchange.HTTP_RESPONSE_CODE
+ "} == 404 ")
.log(org.apache.camel.LoggingLevel.ERROR,
"chouetteRoute.cLog_1", "eRREUR")
.id("cLog_4");
}

 
Eleven Stars

Re: cDynamicRouter and different endpoints

If you look at the screenshot, you can see that the cMessagingEndpoint is working as it should. That is why you are getting row counts after the cMessagingEndpoint. You are getting confused with the terminology. The cMessagingEndpoint is fine and should stay. 
However, I can now see that the service is expecting the body as an instance of org.w3c.dom.Document.  Your service (in Eclipse) is expecting XML as its payload. You need to inform it that you are sending JSON. To do this you might want to try going to the advanced settings of your cHttp components that are calling your Eclipse service and create a new header called "Content-Type" and assigning it a value of "application/json".
The error message below explains that the service wants the body as org.w3c.dom.Document and that is why you are getting this error. You must be really careful to identify the precise error when debugging. This is a completely different error to the one before.
Caused by: org.apache.camel.InvalidPayloadException: No body available of type: org.w3c.dom.Document but has value: org.apache.camel.converter.stream.CachedOutputStream$WrappedInputStream@6c15234e of type: org.apache.camel.converter.stream.CachedOutputStream.WrappedInputStream on: Message: . Caused by: Error during type conversion from type: java.lang.String to the required type: org.w3c.dom.Document with value due org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Contenu non autorisé dans le prologue.. Exchange]. Caused by: due org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Contenu non autorisé dans le prologue.]
Rilhia Solutions
One Star

Re: cDynamicRouter and different endpoints

I must say that I'm confused since when I request the service directly in the browser, without Talend, I get json data
   
** the new header "Content-Type":"application/json" in the cHttp component Get_client doesn't resolve the problem, still getting the error 
: org.apache.camel.component.jetty.JettyHttpComponent - You use localhost interface! It means that no external connections will be available. Don't you want to use 0.0.0.0 instead (all network interfaces)? Endpoint
: org.apache.camel.component.jetty.JettyHttpComponent - Using default Jetty continuation timeout for: Endpoint
: org.eclipse.jetty.server.Server - jetty-8.1.12.v20130726
: org.eclipse.jetty.server.AbstractConnector - Started SelectChannelConnector@localhost:8087
: org.apache.camel.spring.SpringCamelContext - Route: Base_cHttp_1 started and consuming from: Endpoint
: org.apache.camel.spring.SpringCamelContext - Route: cMessagingEndpoint_1 started and consuming from: Endpoint
: org.apache.camel.spring.SpringCamelContext - Total 2 routes, of which 2 is started.
: org.apache.camel.spring.SpringCamelContext - Apache Camel 2.15.2 (CamelContext: cDynamic-ctx) started in 1.143 seconds
: cDynamicRouter.cLog_1 - Exchange]
:1:1: Contenu non autorisé dans le prologue.
: org.slf4j.Logger - Failed delivery for (MessageId: ID-LFR204094-64177-1439558863186-0-3 on ExchangeId: ID-LFR204094-64177-1439558863186-0-1). Exhausted after delivery attempt: 1 caught: org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange]
Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId ProcessorId Processor Elapsed (ms)

]
]
]

choice

Exchange
---------------------------------------------------------------------------------------------------------------------------------------
Exchange
]
Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange]
at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1635)
at org.apache.camel.builder.ExpressionBuilder$42.evaluate(ExpressionBuilder.java:1039)
at org.apache.camel.support.ExpressionAdapter.evaluate(ExpressionAdapter.java:36)
at org.apache.camel.component.bean.MethodInfo$2.evaluateParameterBinding(MethodInfo.java:592)
at org.apache.camel.component.bean.MethodInfo$2.evaluate(MethodInfo.java:484)
at org.apache.camel.component.bean.MethodInfo.createMethodInvocation(MethodInfo.java:240)
at org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:283)
at org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:183)
at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:153)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:68)
at org.apache.camel.language.bean.BeanExpression$InvokeProcessor.process(BeanExpression.java:194)
at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:123)
at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:132)
at org.apache.camel.processor.DynamicRouter$DynamicRoutingSlipIterator.hasNext(DynamicRouter.java:67)
at org.apache.camel.processor.RoutingSlip.doRoutingSlip(RoutingSlip.java:200)
at org.apache.camel.processor.RoutingSlip.process(RoutingSlip.java:146)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:91)
at routines.system.CamelStat$1$1.process(CamelStat.java:56)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:91)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:448)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
at org.apache.camel.component.jetty.CamelContinuationServlet.service(CamelContinuationServlet.java:162)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:686)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1494)
at org.eclipse.jetty.servlets.MultiPartFilter.doFilter(MultiPartFilter.java:136)
at org.apache.camel.component.jetty.CamelFilterWrapper.doFilter(CamelFilterWrapper.java:43)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1465)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:499)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:428)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:370)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:949)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1011)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:668)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.camel.InvalidPayloadException: No body available of type: org.w3c.dom.Document but has value: org.apache.camel.converter.stream.CachedOutputStream$WrappedInputStream@371c24d2 of type: org.apache.camel.converter.stream.CachedOutputStream.WrappedInputStream on: Message: . Caused by: Error during type conversion from type: java.lang.String to the required type: org.w3c.dom.Document with value due org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Contenu non autorisé dans le prologue.. Exchange]. Caused by: due org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Contenu non autorisé dans le prologue.]
at org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:101)
at org.apache.camel.builder.ExpressionBuilder$42.evaluate(ExpressionBuilder.java:1037)
... 47 more
Caused by: org.apache.camel.TypeConversionException: Error during type conversion from type: java.lang.String to the required type: org.w3c.dom.Document with value due org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Contenu non autorisé dans le prologue.
at org.apache.camel.impl.converter.BaseTypeConverterRegistry.createTypeConversionException(BaseTypeConverterRegistry.java:571)
at org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:169)
at org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:99)
... 48 more
Caused by: org.apache.camel.RuntimeCamelException: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Contenu non autorisé dans le prologue.
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1619)
at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1224)
at org.apache.camel.impl.converter.InstanceMethodTypeConverter.convertTo(InstanceMethodTypeConverter.java:78)
at org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:285)
at org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:160)
... 49 more
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Contenu non autorisé dans le prologue.
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
at org.apache.camel.converter.jaxp.XmlConverter.toDOMDocument(XmlConverter.java:853)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1220)
... 52 more
Eleven Stars

Re: cDynamicRouter and different endpoints

Your browser will only ever make a GET call. You are also not sending a payload or a body. When testing REST services that are anything other than GET you really need to use a tool that makes it easy to specify the http verb and supply a payload. Something like Advanced Rest Client (https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo) for Chrome works for me.
Rilhia Solutions
One Star

Re: cDynamicRouter and different endpoints

I was actually using DHC rest Client to specify the HTTP Verb I want to use, sorry didn't mention it before
I used DHC Rest Client to make a direct POST (without using talend) in the service (in eclipse)   using json data, it works:
Eleven Stars

Re: cDynamicRouter and different endpoints

You need to copy the exact settings you use in that to get it to work in Talend. I have just looked at that app and noticed that when you click on the JSON link under the payload, it sets the Content-Type up for you. This will need to be set when you run it via any other system.

Rilhia Solutions
One Star

Re: cDynamicRouter and different endpoints

well, I added a header in the chttp client component, as you can see in the snapshot, in  the POST_server component, the configuration is already set to "application/json"
is there something else I should set?

here's what I got in the debug:
: org.eclipse.jetty.server.AbstractConnector - Started SelectChannelConnector@localhost:8087
: org.apache.camel.spring.SpringCamelContext - Route: base_cHttp_1 started and consuming from: Endpoint
: org.apache.camel.spring.SpringCamelContext - Route: cMessagingEndpoint_1 started and consuming from: Endpoint
: org.apache.camel.spring.SpringCamelContext - Route: cMessagingEndpoint_2 started and consuming from: Endpoint
: org.apache.camel.spring.SpringCamelContext - Route: cMessagingEndpoint_3 started and consuming from: Endpoint
: org.apache.camel.spring.SpringCamelContext - Total 4 routes, of which 4 is started.
: org.apache.camel.spring.SpringCamelContext - Apache Camel 2.15.2 (CamelContext: test2cDynamicRouter-ctx) started in 1.277 seconds
: cDynamicRouter.cLog_1 - Exchange]
:43:7: Le type d'élément "meta" doit se terminer par la balise de fin correspondante "".
: org.apache.camel.processor.DefaultErrorHandler - Failed delivery for (MessageId: ID-LFR204094-53910-1439560830380-0-3 on ExchangeId: ID-LFR204094-53910-1439560830380-0-1). Exhausted after delivery attempt: 1 caught: org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange]
Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId              ProcessorId          Processor                                                                        Elapsed (ms)

                                        ]
                                                   ]
                                                      ]

choice

Exchange
---------------------------------------------------------------------------------------------------------------------------------------
Exchange
]
Eleven Stars

Re: cDynamicRouter and different endpoints

It is now complaining about an XML element called "Meta". You need to focus on one verb at a time. I'd suggest POST. Do not change any of the other routes or use service calls with a verb other than POST. 
Remember where I asked you to add a cProcessor and convert to JSON? Can you replace it with the following code. But only for the POST route....
String jsonString = exchange.getIn().getBody(String.class);
System.out.println(jsonString);
exchange.getIn().setBody(jsonString);

I need to know what is being sent and what the system.out prints to the output. 
Rilhia Solutions
One Star

Re: cDynamicRouter and different endpoints

after adding the cProcessor with the code you've given me;
the debug throws: 
: org.eclipse.jetty.server.AbstractConnector - Started SelectChannelConnector@localhost:8087
: org.apache.camel.spring.SpringCamelContext - Route: base_cHttp_1 started and consuming from: Endpoint
: org.apache.camel.spring.SpringCamelContext - Route: cMessagingEndpoint_2 started and consuming from: Endpoint
: org.apache.camel.spring.SpringCamelContext - Total 2 routes, of which 2 is started.
: org.apache.camel.spring.SpringCamelContext - Apache Camel 2.15.2 (CamelContext: test2cDynamicRouter-ctx) started in 1.119 seconds
:1:1: Contenu non autorisé dans le prologue.
: org.apache.camel.processor.DefaultErrorHandler - Failed delivery for (MessageId: ID-LFR204094-57607-1439562308204-0-2 on ExchangeId: ID-LFR204094-57607-1439562308204-0-1). Exhausted after delivery attempt: 1 caught: org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange]
Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId ProcessorId Processor Elapsed (ms)

]
Exchange
---------------------------------------------------------------------------------------------------------------------------------------
Exchange
]

and the executions' logs: 
from: Endpoint
: org.apache.camel.spring.SpringCamelContext - Route: cMessagingEndpoint_2 started and consuming from: Endpoint
: org.apache.camel.spring.SpringCamelContext - Total 2 routes, of which 2 is started.
: org.apache.camel.spring.SpringCamelContext - Apache Camel 2.15.2 (CamelContext: test2cDynamicRouter-ctx) started in 1.271 seconds
:1:1: Contenu non autorisé dans le prologue.
: org.apache.camel.processor.DefaultErrorHandler - Failed delivery for (MessageId: ID-LFR204094-52305-1439564677351-0-2 on ExchangeId: ID-LFR204094-52305-1439564677351-0-1). Exhausted after delivery attempt: 1 caught: org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange]
Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId ProcessorId Processor Elapsed (ms)

]
Exchange
---------------------------------------------------------------------------------------------------------------------------------------
Exchange
]
One Star

Re: cDynamicRouter and different endpoints

Well, to know   what is being sent and what the system.out prints to the output, I used a cIntercept component and  tried the scenario below; hope it helps: 
One Star

Re: cDynamicRouter and different endpoints

Finally, it works, instead of using the cMessagingEndpoint, I should have chosen the cIntercept component; 
thank you very much for your time and your patient Smiley Happy 
Eleven Stars

Re: cDynamicRouter and different endpoints

I need to see the JSON. Change the cProcessor code to be as below...
String jsonString = exchange.getIn().getBody(String.class);
System.out.println("THE JSON STRING = "+jsonString);
exchange.getIn().setBody(jsonString);

When you run it, look for "THE JSON STRING =" in the output.
Can you also let me know what you supply as JSON when you call it?
Also, can you take a screenshot of route so I can see how far the call got along the route?
This is pretty tricky not being able to play with the route myself.
Rilhia Solutions
One Star

Re: cDynamicRouter and different endpoints

I supply the json object: 
{"id":14,"objectid":"14","objectVersion":14,"creationTime":null,"creatorId":"14","name":"company14","shortName":"","organizationalUnit":"","operatingDepartmentName":"","code":"","phone":"","fax":"","email":"","registrationNumber":"1","ligneses":[],"vehicleJourneyses":[]}

When I run the route, the "THE JSON STRING ="  isn't even printed in the output. I get the same log errors as above. 
here's the screenshot of route:
Eleven Stars

Re: cDynamicRouter and different endpoints

If you look at the screenshot you can see that the message does not make it to cMessagingEndpoint as no rows are shown. Was this a POST call? In your bean that builds the dynamic endpoint, can you put a System.out call to display what it is actually producing?
You are working with a lot of unknowns here. It is always good practise in situations like this to print as much of what is happening to the output as possible.
Rilhia Solutions
One Star

Re: cDynamicRouter and different endpoints

yes, this was a POST call, 
the System.out I added in the bean didn't display anything

public class setDynaURI {
public String setURI(Document document,@Header(Exchange.SLIP_ENDPOINT) String previous, 
@Header(Exchange.HTTP_METHOD) String httpVerb) {
if (previous != null) {
return null;
}
System.out.println("direct:" + httpVerb);
return "direct:" + httpVerb;
}
}
Eleven Stars

Re: cDynamicRouter and different endpoints

That is interesting. It suggests that "previous" is not null and therefore that method is returning null. Can you put ....
System.out.println("Previous = " + previous + " and httpverb = " + httpVerb);
.... before the if condition to the see whether "previous" is null. This could very well be one of your problems.
Rilhia Solutions
One Star

Re: cDynamicRouter and different endpoints

it's not printed neither. 
as I told you, I replaced the cMessagingEndpoint with a cIntercepter, the route works but the
 System.out.println("Previous = " + previous + " and httpverb = " + httpVerb);

 isn't printed either. I think that what's in the bean can't be printed in the Log