I have a simple route which looks like this:
<route handleFault="true" streamCache="true" id="routeA">
<from uri="cxfrs://bean://simpleCxf" />
<log message="The message body contains ${body}"/>
<to uri="direct-vm:RouteB" />
</route>
<route handleFault="true" streamCache="true" id="routeB">
<from uri="direct-vm:RouteB" />
<bean ref="requestValidator" method="validateRequest" />
<log message="The input message ${body}" />
<bean ref="dbClient" method="queryDatabase" />
</route>
the cxf configuration is also pretty simple:
<cxf:rsServer id="simpleCxf" address="/test"
loggingFeatureEnabled="true"
serviceClass="com.gogol.test.TestResource">
</cxf:rsServer>
This simple route fails with the below exception
No type converter available to convert from type: org.apache.cxf.message.MessageContentsList to the required type: org.apache.camel.Exchange with value [com.gogol.test.resource.SimpleObject#773736ca]
This is the message history which suggests that it is failing at the point <bean ref="requestValidator" method="validateRequest" />
Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId ProcessorId Processor Elapsed (ms)
[routeA] [routeA] [direct-vm://routeA ] [6]
[routeB] [log12 ] [log ] [2]
[routeB] [to9 ] [direct-vm:routeA ] [4]
[routeA] [bean26] [bean[ref:requestValidator method: validateRequest]] [2]
I think the issue is that Camel is trying to convert the body generated by cxf to an Exchange object. Because the requestValidator class has a method which has a signature of:
public void validateRequest(Exchange exchange) thows SomeException.
But ideally the message generated by cxf should be set as a body inside Exchange. Am I correct, if not then what could be the reason of the above exception?
EDIT:
I am using CXF version 3.0.4.redhat-621084
and CAMEL version 2.15.1.redhat-621084
{Caused by: org.apache.camel.InvalidPayloadException: No body available of type: org.apache.camel.Exchange but has value: [com.gogol.schema.TestResourcec#6b651b67] of type: org.apache.cxf.message.MessageContentsList on: Message: [com.gogol.schema.TestResourcec#6b651b67]. Caused by: No type converter available to convert from type: org.apache.cxf.message.MessageContentsList to the required type: org.apache.camel.Exchange with value [com.gogol.schema.TestResourcec#6b651b67]. Exchange[Message: [com.gogol.schema.TestResourcec#6b651b67]]. Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: org.apache.cxf.message.MessageContentsList to the required type: org.apache.camel.Exchange with value [com.gogol.schema.TestResourcec#6b651b67]]
at org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:101)[198:org.apache.camel.camel-core:2.15.1.redhat-621084]
at org.apache.camel.builder.ExpressionBuilder$42.evaluate(ExpressionBuilder.java:1037)[198:org.apache.camel.camel-core:2.15.1.redhat-621084]
... 68 more
Caused by: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: org.apache.cxf.message.MessageContentsList to the required type: org.apache.camel.Exchange with value [com.gogol.schema.TestResourcec#6b651b67]
at org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:177)[198:org.apache.camel.camel-core:2.15.1.redhat-621084]
at org.apache.camel.core.osgi.OsgiTypeConverter.mandatoryConvertTo(OsgiTypeConverter.java:122)[203:org.apache.camel.camel-spring:2.15.1.redhat-621084]
at org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:99)[198:org.apache.camel.camel-core:2.15.1.redhat-621084]
... 69 more}
I am not positive on the camel xml dsl how to format this properly, but you can always explicitly tell camel to do a type conversion. You could test your theory by using a convertBodyTo call to force a type conversion.
from("myEndpoint")
.log("This is my previous object")
.convertBodyTo(TestResource.class)
.log("This is my object after a camel type conversion");
Related
I'm trying to set a custom processStrategy in Camel 2.23.2. I've tried several ways to reference it from the processStrategy uri parameter, but I always get this exception:
Caused by: java.lang.IllegalArgumentException: Could not find a suitable setter for property: processStrategy as there isn't a setter method with same type: java.lang.String nor type conversion possible: No type converter available to convert from type: java.lang.String to the required type: org.apache.camel.component.file.GenericFileProcessStrategy with value #genericFileNoOpProcessStrategy"
Route definition
<bean id="genericFileNoOpProcessStrategy" class="org.apache.camel.component.file.strategy.GenericFileNoOpProcessStrategy"/>
<routeContext id="routes" xmlns="http://camel.apache.org/schema/spring">
<route id="route">
<from uri="seda:someEvent"/>
<pollEnrich>
<constant>file:/folder?fileName=file.csv&processStrategy=#genericFileNoOpProcessStrategy"</constant>
</pollEnrich>
What's the right way to reference it?
This would've been working if it weren't a user error (notice the quote "):
<constant>file:/folder?fileName=file.csv&processStrategy=#genericFileNoOpProcessStrategy"</constant>
Fixed with:
<constant>file:/folder?fileName=file.csv&processStrategy=#genericFileNoOpProcessStrategy"</constant>
On placing a bundle (using camel) on Karaf I am seeing the below exception. The below exception comes only when the bundle is started. After that everything works fine. The exeception does not seem to effect our functionality. The issue is coming on both camel 2.16.1 (deployed on servicemix 6.1.0) and camel 2.16.3 (deployed on servicemix 7.0.0M2).
My blueprint is split into three files. A simplified version of them are shown below:-
blueprint.xml placed here.
productBeans.xml placed here.
camelContext.xml placed here.
Can some please let me know why is this exception coming during bundle start? It appears from the below stack-trace that it is because of some circular dependency. How can I get around this?
2016-07-04 11:29:37,497 | ERROR | mix-6.1.0/deploy | BlueprintCamelContext | 143 - org.apache.camel.camel-blueprint - 2.16.1 | {{bundle.id,143}{bundle.name,org.apache.camel.camel-blueprint}{bundle.version,2.16.1}} | Error occurred during starting Camel: CamelContext(camel-1) due Failed to create route orchestrator-service-route at: >>> process[ref:jsonRPCProcessor] <<< in route: Route(orchestrator-service-route)[[From[jetty:http://0.0.0.0... because of Cannot lookup: jsonRPCProcessor from registry: org.apache.camel.blueprint.BlueprintContainerRegistry#7b081b97 with expected type: interface org.apache.camel.Processor due: [BeanRecipe[name='myTemplate'], BeanRecipe[name='.camelBlueprint.bean.factory.myTemplate'], BeanRecipe[name='camel-1'], BeanRecipe[name='myTemplate']]
org.apache.camel.FailedToCreateRouteException: Failed to create route orchestrator-service-route at: >>> process[ref:jsonRPCProcessor] <<< in route: Route(orchestrator-service-route)[[From[jetty:http://0.0.0.0... because of Cannot lookup: jsonRPCProcessor from registry: org.apache.camel.blueprint.BlueprintContainerRegistry#7b081b97 with expected type: interface org.apache.camel.Processor due: [BeanRecipe[name='myTemplate'], BeanRecipe[name='.camelBlueprint.bean.factory.myTemplate'], BeanRecipe[name='camel-1'], BeanRecipe[name='myTemplate']]
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1072)
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:196)
at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:947)
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3258)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:2981)
at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:175)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2812)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2808)
at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2831)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2808)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2777)
at org.apache.camel.blueprint.BlueprintCamelContext.start(BlueprintCamelContext.java:180)[143:org.apache.camel.camel-blueprint:2.16.1]
at org.apache.camel.blueprint.BlueprintCamelContext.maybeStart(BlueprintCamelContext.java:212)[143:org.apache.camel.camel-blueprint:2.16.1]
at org.apache.camel.blueprint.BlueprintCamelContext.serviceChanged(BlueprintCamelContext.java:150)[143:org.apache.camel.camel-blueprint:2.16.1]
at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:932)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:793)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:543)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4419)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.felix.framework.Felix.registerService(Felix.java:3423)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:346)
at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:352)
at org.apache.camel.blueprint.BlueprintCamelContext.init(BlueprintCamelContext.java:100)[143:org.apache.camel.camel-blueprint:2.16.1]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.8.0_77]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)[:1.8.0_77]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.8.0_77]
at java.lang.reflect.Method.invoke(Method.java:498)[:1.8.0_77]
at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:299)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:956)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:712)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:824)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[15:org.apache.aries.blueprint.core:1.4.4]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_77]
at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:247)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintRepository.createInstance(BlueprintRepository.java:230)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintRepository.create(BlueprintRepository.java:145)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.getComponentInstance(BlueprintContainerImpl.java:754)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.camel.blueprint.CamelProducerTemplateFactoryBean.getCamelContextWithId(CamelProducerTemplateFactoryBean.java:49)
at org.apache.camel.core.xml.AbstractCamelFactoryBean.afterPropertiesSet(AbstractCamelFactoryBean.java:54)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.8.0_77]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)[:1.8.0_77]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.8.0_77]
at java.lang.reflect.Method.invoke(Method.java:498)[:1.8.0_77]
at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:299)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:956)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:712)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:824)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[15:org.apache.aries.blueprint.core:1.4.4]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_77]
at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:280)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:806)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[15:org.apache.aries.blueprint.core:1.4.4]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_77]
at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.di.RefRecipe.internalCreate(RefRecipe.java:62)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:106)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.setProperty(BeanRecipe.java:931)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java:905)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java:886)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:820)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[15:org.apache.aries.blueprint.core:1.4.4]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_77]
at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:247)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:183)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:682)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:377)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:269)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:294)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:263)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:253)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:500)[9:org.apache.aries.util:1.1.1]
at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:433)[9:org.apache.aries.util:1.1.1]
at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:725)[9:org.apache.aries.util:1.1.1]
at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:463)[9:org.apache.aries.util:1.1.1]
at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundleTracker.java:422)[9:org.apache.aries.util:1.1.1]
at org.apache.felix.framework.util.SecureAction.invokeBundleEventHook(SecureAction.java:1103)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.felix.framework.util.EventDispatcher.createWhitelistFromHooks(EventDispatcher.java:695)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:483)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4403)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.felix.framework.Felix.startBundle(Felix.java:2092)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.karaf.features.internal.FeaturesServiceImpl.startBundle(FeaturesServiceImpl.java:518)[20:org.apache.karaf.features.core:3.0.5]
at org.apache.karaf.features.internal.FeaturesServiceImpl.installFeatures(FeaturesServiceImpl.java:476)[20:org.apache.karaf.features.core:3.0.5]
at org.apache.karaf.features.internal.FeaturesServiceImpl.installFeature(FeaturesServiceImpl.java:417)[20:org.apache.karaf.features.core:3.0.5]
at Proxy1be55f4b_f63a_43b3_883f_77a48747d768.installFeature(Unknown Source)[:]
at Proxy1fa9f34f_3928_4828_8542_9d785df163bd.installFeature(Unknown Source)[:]
at org.apache.karaf.kar.internal.KarServiceImpl.installFeatures(KarServiceImpl.java:215)[160:org.apache.karaf.kar.core:3.0.5]
at org.apache.karaf.kar.internal.KarServiceImpl.install(KarServiceImpl.java:96)[160:org.apache.karaf.kar.core:3.0.5]
at org.apache.karaf.kar.internal.KarServiceImpl.install(KarServiceImpl.java:84)[160:org.apache.karaf.kar.core:3.0.5]
at Proxya6f8b1d5_e9a2_4e1b_a105_1552c365b9de.install(Unknown Source)[:]
at Proxye3575645_14c4_4cf9_8d71_16cd6e82b1a0.install(Unknown Source)[:]
at org.apache.karaf.deployer.kar.KarArtifactInstaller.install(KarArtifactInstaller.java:50)[162:org.apache.karaf.deployer.kar:3.0.5]
at Proxy6b7a1495_9239_4ff3_b9ed_1fd58a17750b.install(Unknown Source)[:]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.install(DirectoryWatcher.java:931)[7:org.apache.felix.fileinstall:3.5.0]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.install(DirectoryWatcher.java:865)[7:org.apache.felix.fileinstall:3.5.0]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:482)[7:org.apache.felix.fileinstall:3.5.0]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:358)[7:org.apache.felix.fileinstall:3.5.0]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:310)[7:org.apache.felix.fileinstall:3.5.0]
Caused by: org.apache.camel.NoSuchBeanException: Cannot lookup: jsonRPCProcessor from registry: org.apache.camel.blueprint.BlueprintContainerRegistry#7b081b97 with expected type: interface org.apache.camel.Processor due: [BeanRecipe[name='myTemplate'], BeanRecipe[name='.camelBlueprint.bean.factory.myTemplate'], BeanRecipe[name='camel-1'], BeanRecipe[name='myTemplate']]
at org.apache.camel.impl.CompositeRegistry.lookupByNameAndType(CompositeRegistry.java:62)
at org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.lookupByNameAndType(PropertyPlaceholderDelegateRegistry.java:63)
at org.apache.camel.util.CamelContextHelper.lookup(CamelContextHelper.java:137)
at org.apache.camel.util.CamelContextHelper.mandatoryLookup(CamelContextHelper.java:157)
at org.apache.camel.impl.DefaultRouteContext.mandatoryLookup(DefaultRouteContext.java:151)
at org.apache.camel.model.ProcessDefinition.createProcessor(ProcessDefinition.java:95)
at org.apache.camel.model.ProcessorDefinition.makeProcessorImpl(ProcessorDefinition.java:534)
at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:495)
at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:219)
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1069)
... 105 more
Caused by: org.apache.aries.blueprint.di.CircularDependencyException: [BeanRecipe[name='myTemplate'], BeanRecipe[name='.camelBlueprint.bean.factory.myTemplate'], BeanRecipe[name='camel-1'], BeanRecipe[name='myTemplate']]
at org.apache.aries.blueprint.container.BlueprintRepository.push(BlueprintRepository.java:343)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:71)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:247)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintRepository.createInstance(BlueprintRepository.java:230)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintRepository.create(BlueprintRepository.java:145)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.getComponentInstance(BlueprintContainerImpl.java:754)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.camel.blueprint.BlueprintContainerRegistry.lookupByNameAndType(BlueprintContainerRegistry.java:54)
at org.apache.camel.impl.CompositeRegistry.lookupByNameAndType(CompositeRegistry.java:56)
... 114 more
EDIT - It seems the error is because the jsonRPCProcessor is using myTemplate as shown below:-
<bean id="jsonRPCProcessor" class="com.j1.orchestratorservice.basecomponent.processor.JSONRPCProcessor">
<argument ref="myTemplate" />
<argument>
<map>
<!-- Product End Points -->
<entry key="Product.createProducts" value-ref="createProductsWFInfo" />
</map>
</argument>
<argument ref="exceptionHandler" />
</bean>
whereas myTemplate is defined in camelContext which in turn is using jsonRPCProcessor as shown below:-
<camelContext xmlns="http://camel.apache.org/schema/blueprint"
useMDCLogging="true">
<template id="myTemplate" />
<route id="orchestrator-service-route">
<from uri="jetty:http://0.0.0.0:8888/orchestratorservice" />
<process ref="jsonRPCProcessor" />
</route>
<route id="file-upload-service-route">
<from
uri="jetty:http://0.0.0.0:8889/fileuploadservice?enableMultipartFilter=true" />
<process ref="fileUploadProcessor" />
</route>
...
</camelContext>
I have tried to set the producer in my custom Processor as mentioned in this link. Can someone suggest me some other way of setting the producer in my custom jsonRPCProcessor so that it does not lead to any circular dependency?
I am able to get around this by removing myTemplate from jsonRPCProcesor and fileUploadProcessor. Now my jsonRPCProcessor look something like below:-
<bean id="jsonRPCProcessor" class="com.j1.orchestratorservice.basecomponent.processor.JSONRPCProcessor">
<argument>
<map>
<entry key="Product.createProducts" value-ref="createProductsWFInfo" />
</map>
</argument>
<argument ref="exceptionHandler" />
</bean>
Annotated the ProducerTemplate(in the base class) in my code with #EndPointInject. Something like below:-
#EndpointInject
protected ProducerTemplate myTemplate;
I'm trying to learn Camel on Fuse- within this example an ActiveMQ message is converted in a Java object named CustInfo using the Dozer component:
<camelContext id="context-43faded0-825e-454b-8037-c72122aa0418" xmlns="http://camel.apache.org/schema/blueprint">
<propertyPlaceholder location="classpath:sql.properties" id="properties"/>
<endpoint uri="dozer:toCustInfo?sourceModel=homeloancust.CustInfo&targetModel=org.blogdemo.homeloan.model.CustInfo&unmarshalId=homeloancust&mappingFile=toCustInfo.xml" id="toCustInfo"/>
<dataFormats>
<jaxb contextPath="homeloancust" id="homeloancust"/>
</dataFormats>
<route id="CustomerEvaluation">
<from uri="activemq:queue:customer"/>
<to ref="CustInfo" id="to3"/>
. . . .
</route>
</camelContext>
My question is, in case I don't need transformations in the Java object, can I convert the message into the Java class directly (without Dozer).
Tried with:
<bean id="CustInfo" class="homeloancust.CustInfo"/>
. . .
<to ref="CustInfo" id="to3"/>
Without success! Any help ?
Assuming that the incoming message has a contract (which it should if it follows a good contract-first approach), then you can simply unmarshall the payload into a Java object using JAXB. If it doesn't have a contract, you can still annotate your Java class with JAXB annotations and unmarshall to it:
<unmarshal>
<jaxb prettyPrint="true" contextPath="org.apache.camel.example"/>
</unmarshal>
http://camel.apache.org/jaxb.html
I have a Camel route exposed as a CXF web service. This is a bottom up web service and has an operation like so:
List<Book> getBooks();
The CXF endpoint is defined as:
<cxf:cxfEndpoint id="bookService"
address="http://localhost:9045/bookservice"
serviceClass="org.test.cxfws.service.BookDBService">
</cxf:cxfEndpoint>
The operation queries a list of books and returns it to the caller. The Camel route looks like this:
<camel:camelContext xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="cxf:bean:bookService"/>
<choice>
<when>
<simple>${header.operationName} == 'getBooks'</simple>
<to uri="bean:wsImplBean?method=getBooks"/>
</when>
<to uri="log:outboundSoapResponse"/>
<choice>
</route>
</camel:camelContext>
After running the route, I am getting the following exception:
org.apache.cxf.interceptor.Fault: org.test.cxfws.service.Book cannot be cast to java.util.List
at org.apache.cxf.jaxws.interceptors.WrapperClassOutInterceptor.handleMessage(WrapperClassOutInterceptor.java:117)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
at org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:77)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
...
Caused by: java.lang.ClassCastException: org.test.cxfws.service.Book cannot be cast to java.util.List
at org.test.cxfws.service.GetBooksResponse_WrapperTypeHelper1.createWrapperObject(Unknown Source)
at org.apache.cxf.jaxws.interceptors.WrapperClassOutInterceptor.handleMessage(WrapperClassOutInterceptor.java:101)
I can see that the getBooks method from the bean wsImpBean is executed and the result being returned at the end of the choice block inside the route:
[ qtp1653072092-14] outboundSoapResponse INFO Exchange[ExchangePattern: InOut, BodyType: java.util.ArrayList, Body: [org.test.cxfws.service.Book#63f1858b, org.test.cxfws.service.Book#5769bf0, org.test.cxfws.service.Book#2df7ac5d, org.test.cxfws.service.Book#5f55253e, org.test.cxfws.service.Book#4f003a57]]
Can someone help me to understand why the ClassCastException.
Thanks.
As camel-cxf use list to hold the response for handling the InOut parameters. When you set the response result into the message body, you need to wrap the result into a List just like this
List<Book> books ...
List<Object> resultList = new ArrayList<Object>();
resultList.add(books);
exchange.getOut().setBody(resultList);
Spring context:
<bean id="customRouteA" class="com.xxx.CustomRouteABean" />
<camelContext id="solr" xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="activemq:topic:agent" />
<to uri="bean:customRouteA"/>
</route>
</camelContext>
Java code:
public class CustomRouteABean {
#EndpointInject(uri = "http4://localhost/camel-route-test.php")
ProducerTemplate producer;
public void processMessage(#Body String message) {
...
}
}
Keeps getting error:
2085 [main] ERROR org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customRouteA' defined in ServletContext resource [/WEB-INF/application-context.xml]: Initialization of bean failed; nested exception is org.apache.camel.spring.GenericBeansException: Error post processing bean: customRouteA; nested exception is org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: http4://localhost/camel-route-test.php?bridgeEndpoint=true due to: null
I have another bean has the same setup works just fine, what am I missing here?
And you have camel-http4 and its dependent JARs on the classpath?