I'm using apache camel http4 for http server. JBoss Fuse Karaf container 6.3.0.redhat-310 has bundled camel-core 2.17 - (2.17.0.redhat-630310)
I'm trying to use exception class org.apache.camel.component.http.HttpOperationFailedException to catch HTTP response exceptions.
However, the associated routes fail to start due to Caused by: java.lang.ClassNotFoundException: org.apache.camel.component.http.HttpOperationFailedException
I've added as dependency camel-http, with no change, still fails.
It doesn't seem that this class is included anymore?
Q. Is the Caused by: java.lang.ClassNotFoundException: org.apache.camel.component.http.HttpOperationFailedException available to http4 servers, or does anyone know what I'm doing wrong.
<when id="w2">
<ognl>request.headers.TKNDB == true</ognl>
<process id="a3" ref="assetUploadProcessor"/>
<setHeader headerName="CamelHttpUri" id="h1">
<simple>${header.UPLOADURL}</simple>
</setHeader>
<setHeader headerName="CamelHttpMethod" id="h2">
<constant>GET</constant>
</setHeader>
<doTry id="_doTry1">
<to id="http4-1" uri="http4://d1e53858-2903-4c21-86c0-95edc7a5cef2.predix-uaa.run.aws-usw02-pr.ice.predix.io:443/oauth/token?throwExceptionOnFailure=false"/>
<doCatch id="_doCatch1">
<exception>org.apache.camel.component.http.HttpOperationFailedException</exception>
<onWhen>
<simple>${header.HTTP_RESPONSE_CODE} range "400..600"</simple>
</onWhen>
<log id="_log2" loggingLevel="ERROR" message="HTTP FAILURE - HTTP Response Code: ${header.HTTP_RESPONSE_CODE}"/>
</doCatch>
</doTry>
<log id="l1" loggingLevel="INFO" message="JSON Response: ${body}"/>
<process id="jsonmapperassets" ref="jsonMapperAssets"/>
<split id="as1"
YEILDS ... because of org.apache.camel.component.http.HttpOperationFailedException Caused by: java.lang.ClassNotFoundException: org.apache.camel.component.http.HttpOperationFailedException
I've also tried using the Global exception handler using
<exception>org.apache.camel.component.http.HttpOperationFailedException</exception>
<continued>true</continued>
</onException>
but, here I get an ERROR exception saying Continued cannot have children????
thank you!
I just used the simple language to achieve what I needed. I simply need to continue the route after an http error code not OK or 200. this approach works, but I would love to understand how to accomplish this with my original question.
can this be done with camel's http4 component, it appears these classes are not part of it anymore?
also, if someone can, what is wrong with my onException clause?
thanks!
this is what I did
<to id="http4-1" uri="http4://d1e53858-2903-4c21-86c0-95edc7a5cef2.predix-uaa.run.aws-usw02-pr.ice.predix.io:443/oauth/token?throwExceptionOnFailure=false"/>
<choice>
<when>
<simple>${header.CamelHttpResponseCode} == '200'</simple>
<log id="l1" loggingLevel="INFO" message="JSON Response Body: ${body}"/>
<process id="jsonmapperassets" ref="jsonMapperAssets"/>
<split id="as1"
strategyRef="tsAggregationStrategy" streaming="true">
<simple>${body}</simple>
<log id="al6" loggingLevel="INFO" message="Split line ${body}"/>
<process id="p1" ref="getAssets"/>
</split>
<process id="getassetlisting" ref="getAssetListing"/>
<split id="as2"
strategyRef="tsAggregationStrategy" streaming="true">
<simple>${body}</simple>
<log id="sl2" loggingLevel="INFO" message="Split assets ${body}"/>
<process id="gtags" ref="setTagURL"/>
<to id="surl" ref="setURL"/>
</split>
</when>
<otherwise>
<log id="logError1" loggingLevel="ERROR" message="HTTP FAILURE - Response Code: ${header.CamelHttpResponseCode}"/>
<log id="logError2" loggingLevel="ERROR" message="HTTP FAILURE - Response: ${header.CamelHttpResponseText}"/>
</otherwise>
</choice>