[
https://issues.apache.org/jira/browse/CAMEL-7488?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14027520#comment-14027520
]
Willem Jiang edited comment on CAMEL-7488 at 6/11/14 8:09 AM:
--------------------------------------------------------------
Hi Sven,
I managed to reproduce the issue and find out PropertyPlaceholderConfigurer
know nothing about the util:constant as a property.
You have to use it in [a different
way|http://stackoverflow.com/questions/7309956/how-to-reference-constant-in-attribute-in-spring].
I did some work to enable the configuration of "ignoreResourceNotFound", so you
don't need to addition camel:propertyPlaceholder to the camel context there,
the bridgePropertyPlaceHolder could be.
{code}
<bean id="bridgePropertyPlaceHolder"
class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer">
<property name="ignoreResourceNotFound" value="true"/>
<property name="locations">
<list>
<value>classpath:test.properties</value>
</list>
</property>
</bean>
{code}
was (Author: njiang):
Hi Sven,
I managed to reproduce the issue and find out PropertyPlaceholderConfigurer
know nothing about the util:constant as a property.
If have to use it in [a different
way|http://stackoverflow.com/questions/7309956/how-to-reference-constant-in-attribute-in-spring].
I did some work to enable the configuration of "ignoreResourceNotFound", so you
don't need to addition camel:propertyPlaceholder to the camel context there,
the bridgePropertyPlaceHolder could be.
{code}
<bean id="bridgePropertyPlaceHolder"
class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer">
<property name="ignoreResourceNotFound" value="true"/>
<property name="locations">
<list>
<value>classpath:test.properties</value>
</list>
</property>
</bean>
{code}
> PropertiesComponent gets initialized by util:constant
> -----------------------------------------------------
>
> Key: CAMEL-7488
> URL: https://issues.apache.org/jira/browse/CAMEL-7488
> Project: Camel
> Issue Type: Bug
> Components: camel-core, camel-spring
> Affects Versions: 2.13.0, 2.13.1
> Reporter: Sven Nold
> Assignee: Willem Jiang
> Attachments: camel-test.zip
>
>
> Using BridgePropertyPlaceholderConfigurer & Spring util constant namespace
> to reference a static field, the Properties Component gets initialized with
> this constant.
> {code:xml|title=camelContext.xml }
> <util:constant static-field="anypackage.CONSTANT_1"/>
> <bean id="bridgePropertyPlaceHolder"
> class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer">
> <property name="locations">
> <list>
> <value>classpath:test.properties</value>
> </list>
> </property>
> </bean>
> <camel:camelContext xmlns="http://camel.apache.org/schema/spring">
> <camel:route>
> <camel:from uri="direct://ignore" />
> <camel:setBody>
> <camel:simple>{{testProperty}}</camel:simple>
> </camel:setBody>
> <camel:to uri="mock://ignore" />
> </camel:route>
> </camel:camelContext>
> {code}
> Will produce following Stacktrace (constant contained '>>This will be loaded
> as location; but I am simply a constant<<'):
> {noformat}
> Caused by: java.io.FileNotFoundException: Properties file >>This will be
> loaded as location; but I am simply a constant<< not found in classpath
> at
> org.apache.camel.component.properties.DefaultPropertiesResolver.loadPropertiesFromClasspath(DefaultPropertiesResolver.java:96)
> at
> org.apache.camel.component.properties.DefaultPropertiesResolver.resolveProperties(DefaultPropertiesResolver.java:55)
> at
> org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer.resolveProperties(BridgePropertyPlaceholderConfigurer.java:118)
> at
> org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:131)
> at
> org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:117)
> at
> org.apache.camel.impl.DefaultCamelContext.resolvePropertyPlaceholders(DefaultCamelContext.java:1223)
> at
> org.apache.camel.model.ProcessorDefinition.resolvePropertyPlaceholders(ProcessorDefinition.java:571)
> {noformat}
> My current workaround was to specify propertyPlaceholder with empty location
> in camelContext ...
> {code:xml|title=camelContext.xml }
> <!-- same as above -->
> <camel:camelContext xmlns="http://camel.apache.org/schema/spring">
> <!-- location and id are mandatory -->
> <camel:propertyPlaceholder id="stupidMandatoryId" location=""/>
> <camel:route>
> <camel:from uri="direct://ignore" />
> <camel:setBody>
> <camel:simple>{{testProperty}}</camel:simple>
> </camel:setBody>
> <camel:to uri="mock://ignore" />
> </camel:route>
> </camel:camelContext>
> {code}
--
This message was sent by Atlassian JIRA
(v6.2#6252)