Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Zurich on Sept 24th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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 0683p000009MAB6.png
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:
0683p000009MAHp.png 0683p000009MAcR.png
Thank you for your time 
-Regards

Labels (2)
40 Replies
Anonymous
Not applicable
Author

The System.out.println code will print to the output if it is called. I have recreated a basic example emulating what I can see from your code and the System.out.println is called and displayed in the output. I suspect that either the code is not being called or you are missing the text in the output window. Did you actually save the bean before testing, or did you just add the code and run? You must actively save the bean before running the route.
Anonymous
Not applicable
Author

I did save the bean before the bean before running the route, and I checked twice the output 0683p000009MAB6.png  but to be sure,  here's what's printed in the output window: 
 connecting to socket on port 3445
connected
: org.apache.camel.spring.SpringCamelContext - Apache Camel 2.15.2 (CamelContext: cDynamicRouter-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.


To see the whole post, download it here
OriginalPost.pdf
Anonymous
Not applicable
Author

Without looking at the route myself I am afraid I can't really help. You appear to be getting different errors each time and the bean (if it is being called) should be printing the values you've placed in the System.out.println to the output. Calling the System.out.println method is basic Java and will always print out to the registered output. I am not sure why this is not happening for you unless the code is not being called or there is an error which is called first and overrides the call to the System.out (this is a possibility). 
From the last error message you sent it looks like the service is expecting XML. The error message I am talking about is below....
Error during type conversion from type: java.lang.String to the required type: org.w3c.dom.Document with value
I believe that this is connected to the content-type setting. You could try and change this to "text/plain" to see if you can change the error message. It should be "application/JSON", but you say that that is what you have set. 
The other thing to try is to remove the bit of code in the cProcessor that converts the body to a String. Do this to see if there is still an error in converting to an instance of org.w3c.dom.Document.
Anonymous
Not applicable
Author

well after removing the bit of code in the cProcessor, the orute throws the error:
 :1:1: Contenu non autorisé dans le prologue.
: org.slf4j.Logger - Failed delivery for (MessageId: ID-LFR204094-63510-1439797124848-0-2 on ExchangeId: ID-LFR204094-63510-1439797124848-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
]
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.content(AbstractHttpConnection.java:960)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1021)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:865)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
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.InputStreamCache@3055191 of type: org.apache.camel.converter.stream.InputStreamCache 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

when I set the Content-Type to "text/plain" I get this: 
 :1:1: Contenu non autorisé dans le prologue.
: org.slf4j.Logger - Failed delivery for (MessageId: ID-LFR204094-63684-1439797494545-0-2 on ExchangeId: ID-LFR204094-63684-1439797494545-0-1). Exhausted after delivery attempt: 1 caught: org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange]
Anonymous
Not applicable
Author

The important part of the error message in the first error was this.....
Caused by: org.apache.camel.InvalidPayloadException: No body available of type: org.w3c.dom.Document but has value: org.apache.camel.converter.stream.InputStreamCache@3055191 of type: org.apache.camel.converter.stream.InputStreamCache 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

Can you post the complete error stack for the run where you changed the Content-Type to  text/plain?
Anonymous
Not applicable
Author

here it is: 
 connecting to socket on port 3817
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)? Endp


To see the whole post, download it here
OriginalPost.pdf
Anonymous
Not applicable
Author

This is showing the same error. It is expecting XML. The Content-Type header should drive this requirement. If it is set to application/json, I am not sure why this is happening. 
As I said, without actually having the route to look at and test myself, it will be very hard to get much further
Anonymous
Not applicable
Author

Hi again, 
I was a little busy with my exams lately. sorry
well my supervisor wasn't really convinced with the use af a cIntercept component, yes it works just fine but it's not the optimal way. So I searched a little more and I ended with the route bellow (from what I read in the official docs, the cRecipientList is more adequat with I what I want to do than the cDynamicRouter) :
0683p000009MAdA.png
All the configs we've talked about in this post are done: the "Content-Type":"application/json" in the cHttp_client, in the cProcessor components I put: 


To see the whole post, download it here
OriginalPost.pdf
Anonymous
Not applicable
Author

I forgot to menton that with a GET request, in the body, I get the content of this URI
"localhost:8083/Chouette"

even if I put that one
"localhost:8083/Chouette/Companies"

in the REST client. 0683p000009MAWB.png
Anonymous
Not applicable
Author

In the POST error you are seeing an error caused by trying to read an InputStreamCache as a String. You need to convert that  org.apache.camel.converter.stream.InputStreamCache to a String. There is a page on the Apache Camel website that talks about this ( http://camel.apache.org/type-converter.html).