Details
Description
I'm trying to configure Camel AWS Xray tracing via this code
Route:
<bean id="xRayStrategy" class="org.apache.camel.component.aws.xray.TraceAnnotatedTracingStrategy" /> <bean id="aws-xray-tracer" class="org.apache.camel.component.aws.xray.XRayTracer" > <property name="tracingStrategy" ref="xRayStrategy"/> </bean> <camelContext id="zedoc" trace="true" errorHandlerRef="zedocRetryErrorHandler" xmlns="http://camel.apache.org/schema/spring"> <jmxAgent id="agent"/> <errorHandler id="zedocRetryErrorHandler" type="DeadLetterChannel" deadLetterUri="file://{{zedoc.dead.letter.folder}}/" useOriginalMessage="true" onPrepareFailureRef="failureProcessor"> <redeliveryPolicy maximumRedeliveries="5" retryAttemptedLogLevel="WARN" backOffMultiplier="2" useExponentialBackOff="true"/> </errorHandler> <route autoStartup="true" id="fileToMllpServer"> <from uri="file://{{zedoc.hl7.folder}}?delete=true"/> <convertBodyTo type="java.lang.String"/> <log message="The Message body is: ${body}"/> <to uri="netty:tcp://{{zedoc.tcp.host}}:{{zedoc.tcp.port}}?sync=false&decoders=#hl7decoder&encoders=#hl7encoder&ssl=true&sslContextParameters=#sslContextParameters"/> </route> <route autoStartup="true" id="mllpServer"> <from uri="netty:tcp://{{zedoc.tcp.host}}:{{zedoc.tcp.port}}?sync=false&decoders=#hl7decoder&encoders=#hl7encoder&needClientAuth=true&ssl=true&sslContextParameters=#sslContextParameters"/> <log message="The Message body is: ${body}"/> <bean ref="textToJms" method="processADT"/> <log message="The Message body is: ${body}"/> <to uri="amqp:queue:{{zedoc.mq.org}}.{{zedoc.mq.queue}}"/> <!--<to id="_kafka1" uri="kafka:{{producer.topic}}"/>--> </route> </camelContext>
POM:
<!-- aws x-ray --> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-aws-xray</artifactId> <version>3.4.3</version> </dependency> <dependency> <groupId>com.amazonaws</groupId> <artifactId>aws-xray-recorder-sdk-core</artifactId> <version>2.7.1</version> </dependency> <dependency> <groupId>com.amazonaws</groupId> <artifactId>aws-xray-recorder-sdk-aws-sdk</artifactId> <version>2.7.1</version> </dependency>
Processor:
public class ADT01Processor { final Logger logger = LoggerFactory.getLogger(ADT01Processor.class); @Handler public String processADT(Exchange exchange) throws Exception { ADT_A01 inMsg = exchange.getIn().getBody(ADT_A01.class); Terser t = new Terser(inMsg); // create JSON Patient p = new Patient(); String recipientId = t.get("/.PID-3-1"); if(recipientId == null || recipientId.isEmpty()){ throw new Exception("HL7 don't have PID-3-1 that used for mandatory recipientId field"); } Identifier id = new Identifier(recipientId, recipientId); p.addIdetifier(id); String name = t.get("/.PID-5-2"); Name n = new Name(name); p.addName(n); EnrollPatientA01 a01 = new EnrollPatientA01(p); MQMessage outMsg = new MQMessage("fakeGroup"); outMsg.setRawMessage(a01); // stringify Gson gson = new Gson(); String stringifyied = gson.toJson(outMsg); logger.info(stringifyied); return stringifyied; } }
And got an error
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:132) ~[spring-test-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:123) ~[spring-test-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190) ~[spring-test-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132) ~[spring-test-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:244) ~[spring-test-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.test.context.junit.jupiter.SpringExtension.postProcessTestInstance(SpringExtension.java:98) ~[spring-test-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$5(ClassBasedTestDescriptor.java:341) ~[junit-jupiter-engine-5.6.2.jar:5.6.2]
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.executeAndMaskThrowable(ClassBasedTestDescriptor.java:346) ~[junit-jupiter-engine-5.6.2.jar:5.6.2]
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$6(ClassBasedTestDescriptor.java:341) ~[junit-jupiter-engine-5.6.2.jar:5.6.2]
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) ~[na:na]
at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177) ~[na:na]
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655) ~[na:na]
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[na:na]
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na]
at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:312) ~[na:na]
at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735) ~[na:na]
at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734) ~[na:na]
at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658) ~[na:na]
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeTestInstancePostProcessors(ClassBasedTestDescriptor.java:340) ~[junit-jupiter-engine-5.6.2.jar:5.6.2]
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateAndPostProcessTestInstance(ClassBasedTestDescriptor.java:263) ~[junit-jupiter-engine-5.6.2.jar:5.6.2]
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$2(ClassBasedTestDescriptor.java:256) ~[junit-jupiter-engine-5.6.2.jar:5.6.2]
at java.base/java.util.Optional.orElseGet(Optional.java:369) ~[na:na]
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$3(ClassBasedTestDescriptor.java:255) ~[junit-jupiter-engine-5.6.2.jar:5.6.2]
at org.junit.jupiter.engine.execution.TestInstancesProvider.getTestInstances(TestInstancesProvider.java:29) ~[junit-jupiter-engine-5.6.2.jar:5.6.2]
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$prepare$0(TestMethodTestDescriptor.java:108) ~[junit-jupiter-engine-5.6.2.jar:5.6.2]
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.6.2.jar:1.6.2]
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:107) ~[junit-jupiter-engine-5.6.2.jar:5.6.2]
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:71) ~[junit-jupiter-engine-5.6.2.jar:5.6.2]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$1(NodeTestTask.java:107) ~[junit-platform-engine-1.6.2.jar:1.6.2]
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.6.2.jar:1.6.2]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:107) ~[junit-platform-engine-1.6.2.jar:1.6.2]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:75) ~[junit-platform-engine-1.6.2.jar:1.6.2]
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) ~[na:na]
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) ~[junit-platform-engine-1.6.2.jar:1.6.2]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) ~[junit-platform-engine-1.6.2.jar:1.6.2]
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.6.2.jar:1.6.2]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) ~[junit-platform-engine-1.6.2.jar:1.6.2]
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) ~[junit-platform-engine-1.6.2.jar:1.6.2]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) ~[junit-platform-engine-1.6.2.jar:1.6.2]
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.6.2.jar:1.6.2]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) ~[junit-platform-engine-1.6.2.jar:1.6.2]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) ~[junit-platform-engine-1.6.2.jar:1.6.2]
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) ~[na:na]
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) ~[junit-platform-engine-1.6.2.jar:1.6.2]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) ~[junit-platform-engine-1.6.2.jar:1.6.2]
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.6.2.jar:1.6.2]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) ~[junit-platform-engine-1.6.2.jar:1.6.2]
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) ~[junit-platform-engine-1.6.2.jar:1.6.2]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) ~[junit-platform-engine-1.6.2.jar:1.6.2]
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.6.2.jar:1.6.2]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) ~[junit-platform-engine-1.6.2.jar:1.6.2]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) ~[junit-platform-engine-1.6.2.jar:1.6.2]
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) ~[junit-platform-engine-1.6.2.jar:1.6.2]
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) ~[junit-platform-engine-1.6.2.jar:1.6.2]
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) ~[junit-platform-engine-1.6.2.jar:1.6.2]
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:220) ~[junit-platform-launcher-1.3.1.jar:1.3.1]
at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:188) ~[junit-platform-launcher-1.3.1.jar:1.3.1]
at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:202) ~[junit-platform-launcher-1.3.1.jar:1.3.1]
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:181) ~[junit-platform-launcher-1.3.1.jar:1.3.1]
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128) ~[junit-platform-launcher-1.3.1.jar:1.3.1]
at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:150) ~[surefire-junit-platform-2.22.2.jar:2.22.2]
at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:124) ~[surefire-junit-platform-2.22.2.jar:2.22.2]
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384) ~[surefire-booter-2.22.2.jar:2.22.2]
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345) ~[surefire-booter-2.22.2.jar:2.22.2]
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126) ~[surefire-booter-2.22.2.jar:2.22.2]
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418) ~[surefire-booter-2.22.2.jar:2.22.2]
Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route mllpServer at: >>> Bean[ref:textToJms method:processADT] <<< in route: Route(mllpServer)[From[netty:tcp://zedoc.tcp.host:{{zedo... because of class org.apache.camel.processor.WrapProcessor cannot be cast to class org.apache.camel.component.bean.BeanProcessor (org.apache.camel.processor.WrapProcessor and org.apache.camel.component.bean.BeanProcessor are in unnamed module of loader 'app')
at org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:393) ~[camel-core-engine-3.4.3.jar:3.4.3]
at org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:117) ~[camel-core-engine-3.4.3.jar:3.4.3]
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:368) ~[camel-core-engine-3.4.3.jar:3.4.3]
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:342) ~[camel-core-engine-3.4.3.jar:3.4.3]
at org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamelContext.java:2612) ~[camel-base-3.4.3.jar:3.4.3]
at org.apache.camel.support.service.BaseService.init(BaseService.java:83) ~[camel-api-3.4.3.jar:3.4.3]
at org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2435) ~[camel-base-3.4.3.jar:3.4.3]
at org.apache.camel.support.service.BaseService.start(BaseService.java:111) ~[camel-api-3.4.3.jar:3.4.3]
at org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2452) ~[camel-base-3.4.3.jar:3.4.3]
at org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:121) ~[camel-spring-3.4.3.jar:3.4.3]
at org.apache.camel.spring.CamelContextFactoryBean.start(CamelContextFactoryBean.java:381) ~[camel-spring-3.4.3.jar:3.4.3]
at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:428) ~[camel-spring-3.4.3.jar:3.4.3]
at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:96) ~[camel-spring-3.4.3.jar:3.4.3]
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:404) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:361) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:898) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:554) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) ~[spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) ~[spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:120) ~[spring-boot-test-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99) ~[spring-test-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124) ~[spring-test-5.2.8.RELEASE.jar:5.2.8.RELEASE]
... 65 common frames omitted
Caused by: java.lang.ClassCastException: class org.apache.camel.processor.WrapProcessor cannot be cast to class org.apache.camel.component.bean.BeanProcessor (org.apache.camel.processor.WrapProcessor and org.apache.camel.component.bean.BeanProcessor are in unnamed module of loader 'app')
at org.apache.camel.component.aws.xray.TraceAnnotatedTracingStrategy.wrapProcessorInInterceptors(TraceAnnotatedTracingStrategy.java:54) ~[camel-aws-xray-3.5.0.jar:3.5.0]
at org.apache.camel.processor.channel.DefaultChannel.initChannel(DefaultChannel.java:243) ~[camel-base-3.4.3.jar:3.4.3]
at org.apache.camel.reifier.ProcessorReifier.wrapChannel(ProcessorReifier.java:585) ~[camel-core-engine-3.4.3.jar:3.4.3]
at org.apache.camel.reifier.ProcessorReifier.wrapChannel(ProcessorReifier.java:544) ~[camel-core-engine-3.4.3.jar:3.4.3]
at org.apache.camel.reifier.ProcessorReifier.wrapProcessor(ProcessorReifier.java:540) ~[camel-core-engine-3.4.3.jar:3.4.3]
at org.apache.camel.reifier.ProcessorReifier.makeProcessor(ProcessorReifier.java:782) ~[camel-core-engine-3.4.3.jar:3.4.3]
at org.apache.camel.reifier.ProcessorReifier.addRoutes(ProcessorReifier.java:511) ~[camel-core-engine-3.4.3.jar:3.4.3]
at org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:391) ~[camel-core-engine-3.4.3.jar:3.4.3]
... 91 common frames omitted
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 5.388 s <<< FAILURE! - in com.zedoc.integration.hl7.ZedocIntegartionTest
[ERROR] contextLoads Time elapsed: 0.001 s <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route mllpServer at: >>> Bean[ref:textToJms method:processADT] <<< in route: Route(mllpServer)[From[netty:tcp://zedoc.tcp.host:{{zedo... because of class org.apache.camel.processor.WrapProcessor cannot be cast to class org.apache.camel.component.bean.BeanProcessor (org.apache.camel.processor.WrapProcessor and org.apache.camel.component.bean.BeanProcessor are in unnamed module of loader 'app')
Caused by: java.lang.ClassCastException: class org.apache.camel.processor.WrapProcessor cannot be cast to class org.apache.camel.component.bean.BeanProcessor (org.apache.camel.processor.WrapProcessor and org.apache.camel.component.bean.BeanProcessor are in unnamed module of loader 'app')