Camel MQTT Component - Limited number of dynamic endpoints? - apache-camel

We are using Camel MQTT-Component to subscribe to several topics and perform routing logic.
We are using dynamic endpoints in some cases to set the publish topic name at runtime which works up to 15 concurrently connected endpoints.
As soon as the 16-th dynamic endpoint is created (toD()-call) there is a timeout while connecting to the mqtt-Broker.
org.apache.camel.FailedToCreateProducerException: Failed to create Producer for endpoint: <my connection here>&connectAttemptsMax=1&reconnectAttemptsMax=1&publishTopicName=<topic>. Reason: java.util.concurrent.TimeoutException
at org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:579) ~[camel-core-2.18.3.jar:2.18.3]
at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:406) ~[camel-core-2.18.3.jar:2.18.3]
at org.apache.camel.processor.SendDynamicProcessor.process(SendDynamicProcessor.java:119) ~[camel-core-2.18.3.jar:2.18.3]
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77) ~[camel-core-2.18.3.jar:2.18.3]
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:542) ~[camel-core-2.18.3.jar:2.18.3]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197) [camel-core-2.18.3.jar:2.18.3]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:120) ~[camel-core-2.18.3.jar:2.18.3]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:83) ~[camel-core-2.18.3.jar:2.18.3]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197) [camel-core-2.18.3.jar:2.18.3]
at org.apache.camel.component.mqtt.MQTTConsumer.processExchange(MQTTConsumer.java:51) [camel-mqtt-2.18.3.jar:2.18.3]
at org.apache.camel.component.mqtt.MQTTEndpoint$2.onPublish(MQTTEndpoint.java:257) [camel-mqtt-2.18.3.jar:2.18.3]
at org.fusesource.mqtt.client.CallbackConnection$8.onPublish(CallbackConnection.java:521) [mqtt-client-1.14.jar:1.14]
at org.fusesource.mqtt.client.CallbackConnection.toReceiver(CallbackConnection.java:911) [mqtt-client-1.14.jar:1.14]
at org.fusesource.mqtt.client.CallbackConnection.processFrame(CallbackConnection.java:808) [mqtt-client-1.14.jar:1.14]
at org.fusesource.mqtt.client.CallbackConnection.access$1700(CallbackConnection.java:73) [mqtt-client-1.14.jar:1.14]
at org.fusesource.mqtt.client.CallbackConnection$6.onTransportCommand(CallbackConnection.java:425) [mqtt-client-1.14.jar:1.14]
at org.fusesource.hawtdispatch.transport.TcpTransport.drainInbound(TcpTransport.java:713) [hawtdispatch-transport-1.22.jar:1.22]
at org.fusesource.hawtdispatch.transport.TcpTransport$6.run(TcpTransport.java:592) [hawtdispatch-transport-1.22.jar:1.22]
at org.fusesource.hawtdispatch.internal.NioDispatchSource$3.run(NioDispatchSource.java:209) [hawtdispatch-1.22.jar:1.22]
at org.fusesource.hawtdispatch.internal.SerialDispatchQueue.run(SerialDispatchQueue.java:100) [hawtdispatch-1.22.jar:1.22]
at org.fusesource.hawtdispatch.internal.pool.SimpleThread.run(SimpleThread.java:77) [hawtdispatch-1.22.jar:1.22]
Caused by: java.util.concurrent.TimeoutException: null
at org.fusesource.mqtt.client.Promise.await(Promise.java:83) ~[mqtt-client-1.14.jar:1.14]
at org.apache.camel.component.mqtt.MQTTEndpoint.connect(MQTTEndpoint.java:342) ~[camel-mqtt-2.18.3.jar:2.18.3]
at org.apache.camel.component.mqtt.MQTTProducer.doStart(MQTTProducer.java:38) ~[camel-mqtt-2.18.3.jar:2.18.3]
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) ~[camel-core-2.18.3.jar:2.18.3]
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:75) ~[camel-core-2.18.3.jar:2.18.3]
at org.apache.camel.impl.DefaultCamelContext.deferStartService(DefaultCamelContext.java:1316) ~[camel-core-2.18.3.jar:2.18.3]
at org.apache.camel.impl.DefaultCamelContext.doAddService(DefaultCamelContext.java:1244) ~[camel-core-2.18.3.jar:2.18.3]
at org.apache.camel.impl.DefaultCamelContext.addService(DefaultCamelContext.java:1214) ~[camel-core-2.18.3.jar:2.18.3]
at org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:577) ~[camel-core-2.18.3.jar:2.18.3]
... 20 common frames omitted
Is there a limit for concurrent connected Endpoints for Mqtt-Component if these endpoints are created at runtime?
There seems to be no limit for static endpoints. We are able to start up more than 15 routes with endpoints subscribing to topics and consuming messages.
Update: As a fallback we tried to use camel-paho component and it works with the same broker settings and dynamic topic.
Any help with this problem?

While this may be a limitation of camel-mqtt component, you could use one single endpoint and set the publish topic dynamically in a Header.
MQTT component docs suggest the use of CamelMQTTPublishTopic header (from Camel 2.14 onwards), so your route might be like
<route>
<from uri="direct:start" />
<to uri="bean:publishTopicProcessor" />
<to uri="mqtt:singleEndpoint" />
</route>
Inside the processor you can implement all the logic you need
public void process(Exchange exchange) {
String dynamicTopic = "your/dynamic/topic";
// set the topic you want in the string
exchange.getIn().setHeader("CamelMQTTPublishTopic", dynamicTopic);
}
Now the single endpoint will publish your message on different topics.
I did the exact same thing in this example using Camel 2.18

Related

org.apache.camel.NoSuchBeanException for error handler mapped to route

I have the following route definitions file (linehaul-routes.xml):
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://camel.apache.org/schema/spring"
xsi:schemaLocation="
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">
<route id="route1" errorHandlerRef="myErrorHandler">
<from uri="amqp:queue:DSMLH_consignment_event"/> <!-- AMQP queue to which I send messages to trigger the route !-->
<to uri="https://pesho.free.beeceptor.com/"/> <!-- Returns http 500 !-->
</route>
</routes>
I also have a file with error handler in the same directory (linehaul-error-handlers.xml):
<errorHandlers>
<errorHandler id="myErrorHandler" type="DefaultErrorHandler">
<redeliveryPolicy maximumRedeliveries="5" redeliveryDelay="2000"/>
</errorHandler>
</errorHandlers>
And application.properties
camel.context.name=testContext
camel.main.routes-include-pattern=classpath:routes/linehaul-routes.xml,classpath:routes/linehaul-error-handlers.xml
When I run the code I get the following stacktrace
2022-04-27 19:44:53,657 ERROR [org.apa.cam.qua.mai.CamelMainRuntime] (Quarkus Main Thread) [{}] Failed to start application: org.apache.camel.FailedToCreateRouteException: Failed to create route route1 at: >>> To[https://pesho.free.beeceptor.com/] <<< in route: Route(route1)[From[amqp:queue:DSMLH_consignment_event] -> [T... because of No bean could be found in the registry for: myErrorHandler of type: org.apache.camel.ErrorHandlerFactory
at org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:240)
at org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:74)
at org.apache.camel.impl.DefaultModelReifierFactory.createRoute(DefaultModelReifierFactory.java:49)
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:868)
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:758)
at org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamelContext.java:2862)
at org.apache.camel.quarkus.core.FastCamelContext.doInit(FastCamelContext.java:166)
at org.apache.camel.support.service.BaseService.init(BaseService.java:83)
at org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2568)
at org.apache.camel.support.service.BaseService.start(BaseService.java:111)
at org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2587)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:247)
at org.apache.camel.quarkus.main.CamelMain.doStart(CamelMain.java:94)
at org.apache.camel.support.service.BaseService.start(BaseService.java:119)
at org.apache.camel.quarkus.main.CamelMain.startEngine(CamelMain.java:140)
at org.apache.camel.quarkus.main.CamelMainRuntime.start(CamelMainRuntime.java:49)
at org.apache.camel.quarkus.core.CamelBootstrapRecorder.start(CamelBootstrapRecorder.java:45)
at io.quarkus.deployment.steps.CamelBootstrapProcessor$boot173480958.deploy_0(Unknown Source)
at io.quarkus.deployment.steps.CamelBootstrapProcessor$boot173480958.deploy(Unknown Source)
at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
at io.quarkus.runtime.Application.start(Application.java:101)
at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:103)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:67)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:41)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:120)
at io.quarkus.runner.GeneratedMain.main(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:103)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: org.apache.camel.NoSuchBeanException: No bean could be found in the registry for: myErrorHandler of type: org.apache.camel.ErrorHandlerFactory
at org.apache.camel.support.CamelContextHelper.mandatoryLookup(CamelContextHelper.java:241)
at org.apache.camel.model.errorhandler.ErrorHandlerHelper.lookupErrorHandlerFactory(ErrorHandlerHelper.java:82)
at org.apache.camel.reifier.errorhandler.ErrorHandlerRefReifier.lookupErrorHandler(ErrorHandlerRefReifier.java:41)
at org.apache.camel.reifier.errorhandler.ErrorHandlerRefReifier.createErrorHandler(ErrorHandlerRefReifier.java:35)
at org.apache.camel.impl.DefaultModelReifierFactory.createErrorHandler(DefaultModelReifierFactory.java:65)
at org.apache.camel.reifier.ProcessorReifier.wrapInErrorHandler(ProcessorReifier.java:745)
at org.apache.camel.reifier.ProcessorReifier.wrapChannelInErrorHandler(ProcessorReifier.java:726)
at org.apache.camel.reifier.ProcessorReifier.wrapChannel(ProcessorReifier.java:705)
at org.apache.camel.reifier.ProcessorReifier.wrapChannel(ProcessorReifier.java:611)
at org.apache.camel.reifier.ProcessorReifier.wrapProcessor(ProcessorReifier.java:607)
at org.apache.camel.reifier.ProcessorReifier.makeProcessor(ProcessorReifier.java:854)
at org.apache.camel.reifier.ProcessorReifier.addRoutes(ProcessorReifier.java:579)
at org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:236)
... 31 more
What is wrong with the route to error handler mapping ?
(My goal is to make my route to re-try several times on http 500)
Camel Quarkus only supports 'simple' XML routes. You cannot define beans directly like you can with Camel Spring XML.
Instead, you can declare a CDI bean and reference it in the XML. For example.
#Named("myErrorHandler")
public DefaultErrorHandlerBuilder createDefaultErrorHandler() {
return new DefaultErrorHandlerBuilder()
.maximumRedeliveries(5)
.redeliveryDelay(2000);
}
Then you can reference the bean via errorHandlerRef on the route tag.
<route id="route1" errorHandlerRef="myErrorHandler">

IN clause in Apache Camel 2.18

I am trying to execute a sql deletion statement within the route. The query contains an IN clause and I want to pass a Set of values to the IN clause. I am using camel-core & camel-jdbc 2.18.1 and camel-sql 2.18.0
from("direct:deleteRoute").setBody(simple("DELETE FROM TABLE_NAME WHERE ID IN (:#in:idSet)")).to(Constants.JDBC_DATA_SOURCE).end();
Value for idSet is passed in the header of the exchange with key idSet from the route, which calls direct:deleteRoute.
But when I execute I get the following exception.
java.sql.SQLException: A syntax error has occurred.
at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:408)
at com.informix.jdbc.IfxSqli.a(IfxSqli.java:3132)
at com.informix.jdbc.IfxSqli.D(IfxSqli.java:3412)
at com.informix.jdbc.IfxSqli.dispatchMsg(IfxSqli.java:2325)
at com.informix.jdbc.IfxSqli.receiveMessage(IfxSqli.java:2250)
at com.informix.jdbc.IfxSqli.executeExecute(IfxSqli.java:2153)
at com.informix.jdbc.IfxSqli.executeExecute(IfxSqli.java:2133)
at com.informix.jdbc.IfxResultSet.b(IfxResultSet.java:362)
at com.informix.jdbc.IfxStatement.a(IfxStatement.java:1144)
at com.informix.jdbc.IfxStatement.executeImpl(IfxStatement.java:1120)
at com.informix.jdbc.IfxStatement.c(IfxStatement.java:866)
at com.informix.jdbc.IfxStatement.execute(IfxStatement.java:784)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.apache.tomcat.jdbc.pool.StatementFacade$StatementProxy.invoke(StatementFacade.java:114)
at com.sun.proxy.$Proxy105.execute(Unknown Source)
at org.apache.camel.component.jdbc.JdbcProducer.doCreateAndExecuteSqlStatement(JdbcProducer.java:220)
at org.apache.camel.component.jdbc.JdbcProducer.createAndExecuteSqlStatement(JdbcProducer.java:125)
at org.apache.camel.component.jdbc.JdbcProducer.processingSqlBySettingAutoCommit(JdbcProducer.java:86)
at org.apache.camel.component.jdbc.JdbcProducer.process(JdbcProducer.java:67)
at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:542)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:120)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62)
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:542)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:120)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62)
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:542)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:120)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
at org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:117)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:542)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:120)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:192)
at org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:76)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
Caused by: java.sql.SQLException: null
at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:408)
at com.informix.jdbc.IfxSqli.D(IfxSqli.java:3417)
... 53 common frames omitted
This stacktrace comes from camel-jdbc component. This component uses the standard JDBC API, so it takes some limitations from it. One of this is, that you cannot pass collection as single parameter.
In Camel, you can implement custom JdbcPrepareStatementStrategy, register it with uri parameter prepareStatementStrategy to provide custom logic of parsing query, but I wouldn't suggest it. This can lead to lot of traps.
Better use camel-sql component, which uses spring-jdbc and allows this natively since Apache Camel 2.17.
Example with constant prepared statement:
from("direct:deleteIds")
.to("sql:DELETE FROM TABLE_NAME WHERE ID IN (:#in:idSet)");
Example with statement created from body:
from("direct:deleteIds")
.setBody(simple("DELETE FROM TABLE_NAME WHERE ID IN (:?in:idSet)")) // Note questionmark here for specifying parameter. This is difference against query in uri.
.to("direct:executeQuery");
from("direct:executeQuery")
.setHeader(SqlConstants.SQL_QUERY, body())
.to("sql:dummy?dataSource=#datasource");

How to handle file upload with apache-camel restlet component?

I have a front end web-application that uploads a file and other data via a simple form:
<form action="/document/invoice/entity/777" enctype="multipart/form-data">
<input name="file" type="file">
<input name="userId">
<button>Upload File</button>
</form>
and the server side has to be a apache-camel route that handles the uploaded data with restlet component, something similar to this:
<restContext id="myApi" xmlns="http://camel.apache.org/schema/spring">
<rest path="/document">
<post uri="/{documentType}/entity/{entityId}" outType="documentService.Result"
consumes="multipart/form-data" produces="application/json">
<route>
<to uri="bean:documentService?method=validate(${body.file}, ${body.userId}, ${header.documentType}, ${header.entityId})"/>
</route>
</post>
</rest>
</restContext>
With this configuration I'm getting this error:
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
at com.google.gson.Gson.fromJson(Gson.java:822)
at com.google.gson.Gson.fromJson(Gson.java:748)
at org.apache.camel.component.gson.GsonDataFormat.unmarshal(GsonDataFormat.java:105)
at org.apache.camel.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:67)
at org.apache.camel.processor.binding.RestBindingProcessor.process(RestBindingProcessor.java:175)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
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.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:87)
at org.apache.camel.component.http.CamelServlet.service(CamelServlet.java:144)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:537)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1085)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1556)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1513)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:387)
at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.read(MapTypeAdapterFactory.java:183)
at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.read(MapTypeAdapterFactory.java:145)
at com.google.gson.Gson.fromJson(Gson.java:810)
... 36 more
How can I upload files and other data to an apache-camel rest endpoint?
Looks like you have a few configuration issues for how you are passing your data to the restlet component of camel. I would recommend reading the restlet documentation on the camel site: http://camel.apache.org/restlet.html And if you are still having problems here is a link to a full project implementing the restlet server with camel:
http://www.ofbizian.com/2012/02/apache-camel-rest-example.html.
If you are still having issues after checking out those resources please clarify if that exception was from the client or server side.
You are trying to upload some data or file but according to the error it is expecting JSON data, "com.google.gson.JsonSyntaxException" and instead it gets something else. Are you sure the backend part is configured correctly according to what you are sending?

Apache Camel testing webservice authorization 401

I want to test Apache Camel route with jUnit, but unable to set Authorization header for route.
My route looks like
from("direct:test")
.process(new LoggingProcessor())
.to("spring-ws:{{test.domain}}:{{test.port}}/TestChangedSubjects/TestService");
in JUnit I send body with header like
template.sendBodyAndHeader("direct:test", new StringSource(request), "Authorization", "Basic dnJlcG8ycnBvOlZyZXBvMDk4");
Result is Unauthorized [401]
Caused by: org.springframework.ws.client.WebServiceTransportException: Unauthorized [401]
at org.springframework.ws.client.core.WebServiceTemplate.handleError(WebServiceTemplate.java:695)
at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:606)
at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:555)
at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:506)
at org.springframework.ws.client.core.WebServiceTemplate.sendSourceAndReceive(WebServiceTemplate.java:493)
at org.springframework.ws.client.core.WebServiceTemplate.sendSourceAndReceive(WebServiceTemplate.java:483)
at org.apache.camel.component.spring.ws.SpringWebserviceProducer.process(SpringWebserviceProducer.java:89)
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.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:448)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)
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:190)
at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:51)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
at org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:68)
at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:375)
at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:343)
at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:233)
at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:343)
at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:184)
at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:124)
at org.apache.camel.impl.DefaultProducerTemplate.sendBodyAndHeader(DefaultProducerTemplate.java:163)

Trouble using power mock with camel

Since I have to mock a static method, I am using Power Mock to test my application.
My application uses *Camel 2.1*2.
I define routes in XML that is read by camel-spring context.
There were no issues when Junit alone was used for testing.
While using power mock, I get the error listed at the end of the post.
I have also listed the XML used.
Camel is unable to recognize any of its tags when power mock is used.
I wonder whether the byte-level manipulation done by power mock to mock static methods interferes with camel engine in some way. Let me know what could possibly be wrong.
PS:
The problem disappears if I do not use power mock.
+++++++++++++++++++++++++ Error +++++++++++++++++++++++++++++++++++++++++++++++++
[ main] CamelNamespaceHandler DEBUG Using org.apache.camel.spring.CamelContextFactoryBean as CamelContextBeanDefinitionParser
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse JAXB element; nested exception is javax.xml.bind.UnmarshalException: unexpected element (uri:"http://camel.apache.org/schema/spring", local:"camelContext"). Expected elements are <{}aggregate>,<{}aop>,<{}avro>,<{}base64>,<{}batchResequencerConfig>,<{}bean>,<{}beanPostProcessor>,<{}beanio>,<{}bindy>,<{}camelContext>,<{}castor>,<{}choice>,<{}constant>,<{}consumerTemplate>,<{}contextScan>,<{}convertBodyTo>,<{}crypto>,<{}csv>,<{}customDataFormat>,<{}customLoadBalancer>,<{}dataFormats>,<{}delay>,<{}description>,<{}doCatch>,<{}doFinally>,<{}doTry>,<{}dynamicRouter>,<{}el>,<{}endpoint>,<{}enrich>,<{}errorHandler>,<{}export>,<{}expression>,<{}expressionDefinition>,<{}failover>,<{}filter>,<{}flatpack>,<{}from>,<{}groovy>,<{}gzip>,<{}header>,<{}hl7>,<{}idempotentConsumer>,<{}inOnly>,<{}inOut>,<{}intercept>,<{}interceptFrom>,<{}interceptToEndpoint>,<{}javaScript>,<{}jaxb>,<{}jibx>,<{}jmxAgent>,<{}json>,<{}jxpath>,<{}keyStoreParameters>,<{}language>,<{}loadBalance>,<{}log>,<{}loop>,<{}marshal>,<{}method>,<{}multicast>,<{}mvel>,<{}ognl>,<{}onCompletion>,<{}onException>,<{}optimisticLockRetryPolicy>,<{}otherwise>,<{}packageScan>,<{}pgp>,<{}php>,<{}pipeline>,<{}policy>,<{}pollEnrich>,<{}process>,<{}properties>,<{}property>,<{}propertyPlaceholder>,<{}protobuf>,<{}proxy>,<{}python>,<{}random>,<{}recipientList>,<{}redeliveryPolicy>,<{}redeliveryPolicyProfile>,<{}ref>,<{}removeHeader>,<{}removeHeaders>,<{}removeProperty>,<{}resequence>,<{}rollback>,<{}roundRobin>,<{}route>,<{}routeBuilder>,<{}routeContext>,<{}routeContextRef>,<{}routes>,<{}routingSlip>,<{}rss>,<{}ruby>,<{}sample>,<{}secureRandomParameters>,<{}secureXML>,<{}serialization>,<{}setBody>,<{}setExchangePattern>,<{}setFaultBody>,<{}setHeader>,<{}setOutHeader>,<{}setProperty>,<{}simple>,<{}soapjaxb>,<{}sort>,<{}spel>,<{}split>,<{}sql>,<{}sslContextParameters>,<{}sticky>,<{}stop>,<{}streamCaching>,<{}streamResequencerConfig>,<{}string>,<{}syslog>,<{}template>,<{}threadPool>,<{}threadPoolProfile>,<{}threads>,<{}throttle>,<{}throwException>,<{}tidyMarkup>,<{}to>,<{}tokenize>,<{}topic>,<{}transacted>,<{}transform>,<{}unmarshal>,<{}validate>,<{}vtdxml>,<{}weighted>,<{}when>,<{}wireTap>,<{}xmlBeans>,<{}xmljson>,<{}xmlrpc>,<{}xpath>,<{}xquery>,<{}xstream>,<{}zip>,<{}zipFile> at org.apache.camel.spring.handler.CamelNamespaceHandler.parseUsingJaxb(CamelNamespaceHandler.java:169)
at org.apache.camel.spring.handler.CamelNamespaceHandler$CamelContextBeanDefinitionParser.doParse(CamelNamespaceHandler.java:307)
at org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser.parseInternal(AbstractSingleBeanDefinitionParser.java:85)
at org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.parse(AbstractBeanDefinitionParser.java:59)
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1438)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1428)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:185)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:139)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:108)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:243)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at org.apache.camel.spring.SpringCamelContext.springCamelContext(SpringCamelContext.java:100)
at com.ericsson.bss.edm.integrationFramework.Context.<init>(Context.java:50)
at com.ericsson.bss.edm.integrationFramework.RouteEngine.main(RouteEngine.java:55)
at com.ericsson.bss.edm.integrationFramework.RouteEngineTest.testMultiRouteCondition(RouteEngineTest.java:174)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:66)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:312)
at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:86)
at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:94)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:296)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTestInSuper(PowerMockJUnit47RunnerDelegateImpl.java:112)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTest(PowerMockJUnit47RunnerDelegateImpl.java:73)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:284)
at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:84)
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:49)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:209)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:148)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:122)
at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34)
at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:120)
at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:102)
at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:53)
at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:42)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:24)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at org.junit.runner.JUnitCore.run(JUnitCore.java:136)
at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.execute(JUnitCoreWrapper.java:62)
at org.apache.maven.surefire.junitcore.JUnitCoreProvider.invoke(JUnitCoreProvider.java:139)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: javax.xml.bind.UnmarshalException: unexpected element (uri:"http://camel.apache.org/schema/spring", local:"camelContext"). Expected elements are <{}aggregate>,<{}aop>,<{}avro>,<{}base64>,<{}batchResequencerConfig>,<{}bean>,<{}beanPostProcessor>,<{}beanio>,<{}bindy>,<{}camelContext>,<{}castor>,<{}choice>,<{}constant>,<{}consumerTemplate>,<{}contextScan>,<{}convertBodyTo>,<{}crypto>,<{}csv>,<{}customDataFormat>,<{}customLoadBalancer>,<{}dataFormats>,<{}delay>,<{}description>,<{}doCatch>,<{}doFinally>,<{}doTry>,<{}dynamicRouter>,<{}el>,<{}endpoint>,<{}enrich>,<{}errorHandler>,<{}export>,<{}expression>,<{}expressionDefinition>,<{}failover>,<{}filter>,<{}flatpack>,<{}from>,<{}groovy>,<{}gzip>,<{}header>,<{}hl7>,<{}idempotentConsumer>,<{}inOnly>,<{}inOut>,<{}intercept>,<{}interceptFrom>,<{}interceptToEndpoint>,<{}javaScript>,<{}jaxb>,<{}jibx>,<{}jmxAgent>,<{}json>,<{}jxpath>,<{}keyStoreParameters>,<{}language>,<{}loadBalance>,<{}log>,<{}loop>,<{}marshal>,<{}method>,<{}multicast>,<{}mvel>,<{}ognl>,<{}onCompletion>,<{}onException>,<{}optimisticLockRetryPolicy>,<{}otherwise>,<{}packageScan>,<{}pgp>,<{}php>,<{}pipeline>,<{}policy>,<{}pollEnrich>,<{}process>,<{}properties>,<{}property>,<{}propertyPlaceholder>,<{}protobuf>,<{}proxy>,<{}python>,<{}random>,<{}recipientList>,<{}redeliveryPolicy>,<{}redeliveryPolicyProfile>,<{}ref>,<{}removeHeader>,<{}removeHeaders>,<{}removeProperty>,<{}resequence>,<{}rollback>,<{}roundRobin>,<{}route>,<{}routeBuilder>,<{}routeContext>,<{}routeContextRef>,<{}routes>,<{}routingSlip>,<{}rss>,<{}ruby>,<{}sample>,<{}secureRandomParameters>,<{}secureXML>,<{}serialization>,<{}setBody>,<{}setExchangePattern>,<{}setFaultBody>,<{}setHeader>,<{}setOutHeader>,<{}setProperty>,<{}simple>,<{}soapjaxb>,<{}sort>,<{}spel>,<{}split>,<{}sql>,<{}sslContextParameters>,<{}sticky>,<{}stop>,<{}streamCaching>,<{}streamResequencerConfig>,<{}string>,<{}syslog>,<{}template>,<{}threadPool>,<{}threadPoolProfile>,<{}threads>,<{}throttle>,<{}throwException>,<{}tidyMarkup>,<{}to>,<{}tokenize>,<{}topic>,<{}transacted>,<{}transform>,<{}unmarshal>,<{}validate>,<{}vtdxml>,<{}weighted>,<{}when>,<{}wireTap>,<{}xmlBeans>,<{}xmljson>,<{}xmlrpc>,<{}xpath>,<{}xquery>,<{}xstream>,<{}zip>,<{}zipFile>
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:647)
at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:258)
at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:253)
at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:120)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext$DefaultRootLoader.childElement(UnmarshallingContext.java:1052)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:483)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:464)
at com.sun.xml.bind.v2.runtime.unmarshaller.InterningXmlVisitor.startElement(InterningXmlVisitor.java:75)
at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:152)
at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:244)
at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:127)
at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:105)
at com.sun.xml.bind.v2.runtime.BinderImpl.associativeUnmarshal(BinderImpl.java:161)
at com.sun.xml.bind.v2.runtime.BinderImpl.unmarshal(BinderImpl.java:132)
at org.apache.camel.spring.handler.CamelNamespaceHandler.parseUsingJaxb(CamelNamespaceHandler.java:167)
... 72 more
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++ Route.xml +++++++++++++++++++++++++++++++++++++++++++++
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route id="simpleroute">
<from uri="ftp://admin#x.y.z.a:2121/?password=admin&noop=true&maximumReconnectAttempts=3&download=false&delay=2000&throwExceptionOnConnectFailed=true;"/>
<to uri="file:/home/emeensa/NetBeansProjects/CamelFileCopier/output" />
</route>
</camelContext>
</beans>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
When you have these JAXB binding errors with spring then in the past it has been troubles with JAXB version. Can you check the classpath if you have JAXB 2.1 or 2.2. Sometimes the JAXB that comes witht the JDK is too old and buggy, and you may need to have JAXB added to your classpath.
Another idea could be that the error says it does not understand the local namespace. You can try using a prefix, eg such as camel in the XML top, and use
<camel:camelContext>
instead.
I got this to work as follows :
#RunWith(PowerMockRunner.class)
#PowerMockIgnore({"org.xml.*", "javax.xml.*", "org.springframework.*","org.apache.commons.logging.*","org.w3c.*","javax.management.*"})
The list of packages in the #PowerMockIgnore annotation was found by trial and error and I have pretty much no idea what I have done, but my unit test now runs and produces the same results as when I didn't use the #RunWith annotation.

Resources