camel-sql is unable to resolve property placeholder

Solution Verified - Updated -

Issue

  • camel-sql is unable to resolve property placeholder when SQL Query is externalized to properties files.
  • Sample camel-context and property file.
<camelContext id="_camelContext1" xmlns="http://camel.apache.org/schema/spring">
        <propertyPlaceholder id="placeholder" location="ref:props" />
        <route id="_route1">
            <from id="_from1" uri="timer://foo?repeatCount=1" />
            <setProperty id="_setProperty1" propertyName="myId">
                <simple>1234</simple>
            </setProperty>
            <log id="_log2" message="Print myId:${property.localTxnDtTime}" />
            <toD id="_to1" uri="sql:{{sql.select}}" />
        </route>
</camelContext>
<bean class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer"
        id="props">
        <property name="location"
            value="classpath:properties/com.sql.example.properties" />
</bean>

#com.sql.example.properties
sql.select=select * from table where id=:#${property.myId} order by name?dataSource=#dataSource
  • Below exception is thrown
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'property.myId' in string value "sql:select * from table where id=:#${property.myId} order by name?dataSource=#dataSource"
    at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:173)
    at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:125)
    at org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer.springResolvePlaceholders(BridgePropertyPlaceholderConfigurer.java:207)
    at org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer.parseUri(BridgePropertyPlaceholderConfigurer.java:170)
    at org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:209)
    at org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:160)
    at org.apache.camel.impl.DefaultCamelContext.resolvePropertyPlaceholders(DefaultCamelContext.java:2305)
    at org.apache.camel.model.ProcessorDefinitionHelper.resolvePropertyPlaceholders(ProcessorDefinitionHelper.java:734)
    at org.apache.camel.model.ProcessorDefinition.makeProcessorImpl(ProcessorDefinition.java:509)
    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)
    ... 32 more

Environment

  • Red Hat JBoss Fuse
    • 6.3.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content