Property value is not access - apache-camel

I am beginner for camel. I have some problem.
We are implementing file transfer system using camel.
I set property from external property file.
But application is not accessed to this property file. We cannot use propertyplaceholder because the value will be changed at runtime.
We implemented it like below.
camelContext.xml :
<bean id="myProperties" class="java.util.Properties"/>
<bean id="propertylist"
class="org.apache.camel.component.properties.PropertiesComponent">
<property name="cache" value="true"/>
<property name="location" value="classpath:camelap.properties"/>
<property name="overrideProperties" ref="myProperties"/>
</bean>
<camelContext id="camelContext-f611cb6c-d516-4346-9adc-5512d327a88d"
trace="false" xmlns="http://camel.apache.org/schema/spring">
<camel:route id="initial_info">
<camel:from id="_initial" uri="direct:sqlParam"/>
<camel:to id="_selectReference" uri="sql:{{sql.referenceInfo}}?
dataSource=dataSource"/>
<camel:process id="_process1" ref="tempBean"/>
<camel:log id="_aaaa" loggingLevel="WARN" message="tttttttt :::
{{test}} ::: ${header.sourceDirectory}"/>
</camel:route>
camelap.properties :
path : target/classes
file.uri=/home/WRK/KR/SND/DAT
test=OLD_VALUE
file.pattern=SLPNPM*,SPLNCC*,SLPNCM*,SLPNPC*
############################################
## SQL Statement ##
############################################
sql.referenceInfo=SELECT DISTINCT \
A.WFLOW_INST_ID ,\
TO_CHAR(A.EFCT_ST_DT,'YYYYMMDDHH24MISS') EFCT_ST_DT, \
B.NE_ID , \
B.NE_TYPE_ID , \
B.CDR_FILE_COLEC_DIR_NM , \
B.ORIGIN_FMT_ID , \
B.TRM_DIR_NM , \
D.CDR_FILE_NMNG_RULE_SBST, \
D.FILE_NM_LEN , \
B.FNS_FILE_CRET_YN , \
B.FNS_FILE_DIV_CD \
FROM TB_WFLOW_INFO A, \
TB_CDRSEND_BASE_INFO B, \
TB_FILE_FMT_INFO D \
WHERE A.WFLOW_INST_ID = 'P1_IPTVKR' \
AND B.NE_ID = 'KRLPPM10' \
AND now() BETWEEN A.EFCT_ST_DT AND A.EXP_DT \
AND now() BETWEEN B.EFCT_ST_DT AND B.EXP_DT \
AND A.WFLOW_INST_ID = B.WFLOW_INST_ID \
AND B.ORIGIN_FMT_ID = D.CDR_FILE_FMT_ID;
Error Log :
org.apache.camel.RuntimeCamelException:
org.apache.camel.FailedToCreateRouteException: Failed to create route initial_info at: >>> To[sql:{{sql.referenceInfo}}?dataSource=dataSource] <<< in route: Route(initial_info)[[From[direct:sqlParam]] -> [To[sql:{{sql... because of Property with key [sql.referenceInfo] not found in properties from text: sql:{{sql.referenceInfo}}?dataSource=dataSource
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1826) ~[camel-core-2.23.1.jar:2.23.1]
at org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:136) ~[camel-spring-2.23.1.jar:2.23.1]
at org.apache.camel.spring.CamelContextFactoryBean.start(CamelContextFactoryBean.java:370) ~[camel-spring-2.23.1.jar:2.23.1]
at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:417) ~[camel-spring-2.23.1.jar:2.23.1]
at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:95) ~[camel-spring-2.23.1.jar:2.23.1]
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:402) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:359) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:896) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:163) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at com.ktds.openmzn.OpenmznApplication.main(OpenmznApplication.java:25) ~[classes/:na]
.....
Caused by: java.lang.IllegalArgumentException: Property with key [sql.referenceInfo] not found in properties from text: sql:{{sql.referenceInfo}}?dataSource=dataSource
at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.getPropertyValue(DefaultPropertiesParser.java:271) ~[camel-core-2.23.1.jar:2.23.1]
at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.readProperty(DefaultPropertiesParser.java:157) ~[camel-core-2.23.1.jar:2.23.1]
at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.doParse(DefaultPropertiesParser.java:116) ~[camel-core-2.23.1.jar:2.23.1]
at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.parse(DefaultPropertiesParser.java:100) ~[camel-core-2.23.1.jar:2.23.1]
at org.apache.camel.component.properties.DefaultPropertiesParser.parseUri(DefaultPropertiesParser.java:63) ~[camel-core-2.23.1.jar:2.23.1]
at org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:235) ~[camel-core-2.23.1.jar:2.23.1]
at org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:178) ~[camel-core-2.23.1.jar:2.23.1]
at org.apache.camel.impl.DefaultCamelContext.resolvePropertyPlaceholders(DefaultCamelContext.java:2547) ~[camel-core-2.23.1.jar:2.23.1]

If you want to use the properties component, you need to bind a name with properties, just like this.
<camelContext trace="{{foo.trace}}" xmlns="http://camel.apache.org/schema/spring">
<propertyPlaceholder id="properties" location="org/apache/camel/spring/processor/myprop.properties"/>
<template id="camelTemplate" defaultEndpoint="{{foo.cool}}"/>
<route>
<from uri="direct:start"/>
<setHeader headerName="{{foo.header}}">
<simple>${in.body} World!</simple>
</setHeader>
<to uri="mock:result"/>
</route>
</camelContext>
You can find more information here
Not sure if you are using spring boot, there is a simple way to leverage the spring boot properties within Camel Route.

Related

Failed to create route route-t: >>> OnException[[com.sample] ->

I am migrating from camle 2 to camel 3 as below configuration
<onException>
<exception>com.sample</exception>
<redeliveryPolicy disableRedelivery="true"/>
<handled>
<constant>true</constant>
</handled>
<log message="got here, before predict, ${exchangeProperty.firstCall}" loggingLevel="INFO"/>
<choice>
<when>
<method>operation</method>
<bean ref="Procs" method="SampleCommentRequestForError"/>
<setProperty propertyName="firstCall">
<constant>false</constant>
</setProperty>
<log message="got here, after predict, ${exchangeProperty.firstCallOf}" loggingLevel="INFO"/>
<to uri="direct:sample-comment"/>
</when>
</choice>
<bean ref="abc_errorhandler" method="abcException"/>
</onException>
and getting below exception :
Failed to create route route-nsm-client-call at: >>> OnException[[com.sample] -> [Log[got here, before predict, ${exchangeProperty.firstCall], Choice[[When[bean{abc} [From[direct:bbc-call ->... because of Bean language requires bean, beanType, or ref argument
Caused by: java.lang.IllegalArgumentException: Bean language requires bean, beanType, or ref argument
Any idea on this?
This will work camel 2.x operation but if you try to upgrade camel 3.x for existing code. So, in that case you need to change this code to like below sample . but rather than myBean provide whole class package path.
Try below sample code..
for more details, please check below official website..
https://camel.apache.org/components/3.17.x/languages/bean-language.html

How to make Camel pattern="InOut" work with IBM MQ

As described here:
setting ReplyToQ attribute of MQMD of IBM MQ request message with Camel
I managed to set ReplyToQ in MQMD of request properly in Camel Route, but I can't get the response in the same Route, with the IBM MQ Endpoint ("to") that I would like to use both for output (of request) and for input (of response), because it is matching wrong Correlation ID, like this:
The OUT message was not received within: 20000 millis due reply message with correlationID: Camel-ID-MYPC-62418-1518179436629-0-5 not received on destination: queue:///REPLYQ. Exchange[ID-MYPC-62418-1518179436629-0-4]
Namely, responding application sets CorrelationID (in MQMD) to the MessageID (from MQMD of the received request). How to make this scenario work?
I tried with useMessageIDAsCorrelationID, but this doesn't change much the result (responses are not consumed). Another try was to set MessageID of request to some fixed value (that would not be final solution), but I can't even do that. I added this:
<setHeader headerName="JMSMessageID" id="_setHeader2">
<constant>abcdefg</constant>
</setHeader>
<setHeader headerName="JMSCorrelationID" id="_setHeader3">
<constant>abcdefg</constant>
</setHeader>
but this only sets CorrelationID, and I still get such things:
The OUT message was not received within: 20000 millis due reply message with correlationID: abcdefg not received on destination: queue:///REPLYQ. Exchange[ID-MYPC-65151-1518190285422-0-3]
Complete route definition:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:camel="http://camel.apache.org/schema/spring"
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.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean class="org.apache.camel.component.jms.JmsComponent" id="websphere">
<property name="connectionFactory">
<bean class="com.ibm.mq.jms.MQConnectionFactory">
<property name="transportType" value="1"/>
<property name="hostName" value="hostname"/>
<property name="port" value="port"/>
<property name="queueManager" value="qmgr_name"/>
<property name="channel" value="channel_name"/>
</bean>
</property>
</bean>
<!-- Define a traditional camel context here -->
<camelContext id="camel" useBreadcrumb="false" xmlns="http://camel.apache.org/schema/spring">
<route id="simple-route">
<from id="request-file" uri="file://C:/mqdocuments/?fileName=request.txt"/>
<log id="route-log" message=">>> ${body}"/>
<setHeader headerName="CamelJmsDestinationName" id="_setHeader1">
<constant>queue://QM_TEST/INPUTQ?targetClient=1&mdWriteEnabled=true&mdReadEnabled=true</constant>
</setHeader>
<setHeader headerName="JMSMessageID" id="_setHeader2">
<constant>abcdefg</constant>
</setHeader>
<setHeader headerName="JMSCorrelationID" id="_setHeader3">
<constant>abcdefg</constant>
</setHeader>
<to id="_to1" pattern="InOut" uri="websphere:queue:SYSTEM.DEFAULT.LOCAL.QUEUE?replyTo=REPLYQ"/>
</route>
</camelContext>
</beans>
OK, this simple code actually works as explained here:
http://camel.apache.org/correlation-identifier.html
<route id="simple-route">
<from id="request-file" uri="file://C:/mqdocuments/?fileName=request464.txt"/>
<log id="route-log-request" message="request: ${body}"/>
<setHeader headerName="CamelJmsDestinationName" id="_setHeader1">
<constant>queue://QM_TEST/INPUTQ?targetClient=1</constant>
</setHeader>
<to id="_to1" pattern="InOut" uri="websphere:queue:SYSTEM.DEFAULT.LOCAL.QUEUE?useMessageIDAsCorrelationID=true&replyTo=REPLYQ"/>
<log id="route-log-response" message="response: ${body}"/>
</route>
It prints out neatly response body to console output.
I don't know why I was under impression that it doesn't work when I first tried it. So, to summarize both questions, the catch is in using useMessageIDAsCorrelationID and replyTo parameters in uri of a queue, as well as pattern="InOut" parameter of <to> endpoint.

Error occurred during camel start because of circular dependency

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;

camel property file not found in class path

I'm trying to read property file from class path.
I have project name - PROG , under it there is a folder named resources and in it there is a property file : myProp
In camel context xml my code is :
<propertyPlaceholder id="properties" location="classpath:PROG.resources.myProp" />
I tried too :
<propertyPlaceholder id="properties" location="classpath:resources.myProp" />
but I get camel error :
java.io.FileNotFoundException: Properties file PROG.resources.myProp not found in classpath
Any idea?
I'm using this XML code to configure a property placeholder:
<propertyPlaceholder id="properties" location="classpath:/resources/myProp" />
Here's the official example from https://camel.apache.org/using-propertyplaceholder.html:
<bean id="properties" class="org.apache.camel.component.properties.PropertiesComponent">
<property name="location" value="classpath:com/mycompany/myprop.properties"/>
</bean>
Try using a real path, not the "." notation from ResourceBundle.

Reading Camel Constant From Property file

I am trying to read time delay from property file .
have defined in my property file :
time_inMilis=15000
I have configured my camel context xml to be :
<bean id="property" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>file:/D:/Develop/resources/my.properties
</value>
</property>
</bean>
<camel:camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<propertyPlaceholder id="properties" location="file:/D:/Develop/resources/my.properties"/>
<camel:route id="delayQueue">
<camel:from uri="seda:queue1" />
<delay asyncDelayed="true">
<constant>${time_inMilis}</constant>
</delay>
<camel:to uri="seda:queue2" />
</camel:route>
</camel:camelContext>
camel do not throw any error but it seems that it ignores ${time_inMilis} and set 0 for my delay time.
What is the right way to read the delay constant from my property file ?
First, it would be enough just to use camel:propertyPlaceholder instead of declaring bean property.
Second mistake is that you are using Constant instead of Simple expression when trying to read your time_inMilis property value.
Third, when trying to get value of you property, you should specifically tell Camel that your are looking at properties.
If your context defines propertiesPlaceholder like this:
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<propertyPlaceholder id="props" location="classpath:/org/smp/eip/sample.properties"/>
<package>org.apache.camel.example.spring</package>
</camelContext>
them with java DSL you'll be able to read the textProeprty value like this
from("file:src/data?noop=true")
.transform().simple("Text read from properties: ${properties:textProperty}")
.bean(new SomeBean());
Using Spring DSL from your original post, the correct way of reading property would be:
<camel:route id="delayQueue">
<camel:from uri="seda:queue1" />
<delay asyncDelayed="true">
<simple>${properties:time_inMilis}</simple>
</delay>
<camel:to uri="seda:queue2" />
</camel:route>

Resources