If you use spring, then all the <bean> is spring's property
placeholder that handles that.
And spring uses ${ } syntax.
So change
<property name="username" value="{{datasource.stg.username}}"/>
To use ${ }
All inside <camelContext> is Camel. And uses {{ }} syntax.
See also
http://camel.apache.org/how-do-i-use-spring-property-placeholder-with-camel-xml.html
On Sat, Nov 16, 2013 at 2:45 PM, Joao Vicente
<[email protected]> wrote:
> I am having some trouble getting a data source setup using Camel properties
> component.
> So, I have a db.properties that contains configuration for my datasource
> (showing only url for brevity)
> My route builder seems to be able to resolve the property, but the data
> source does not seem to do so.
> The evidence for this is shown in the console output below.
> I wonder could anyone shed some light to why this could be happening?
>
>
> db.properties
> datasource.stg.url=jdbc:oracle:thin:...
>
> camel-context.xml
> ...
> <bean id="properties"
> class="org.apache.camel.component.properties.PropertiesComponent">
> <property name="location" value="classpath:db.properties"/>
> </bean>
>
> <bean id="auditDataSourceStg"
> class="org.apache.commons.dbcp.BasicDataSource">
> <property name="driverClassName"
> value="oracle.jdbc.driver.OracleDriver"/>
> <property name="url" value="{{datasource.stg.url}}"/>
> <property name="username"
> value="{{datasource.stg.username}}"/>
> <property name="password"
> value="{{datasource.stg.password}}"/>
> <property name="initialSize" value="5" />
> <property name="maxActive" value="10" />
> </bean>
> ...
>
> MyRouteBuilder.java
> ...
> public void configure() {
> from(fromQueryBuilder)
> .log("[queryyBuilder] url:{{datasource.stg.url}}")
>
> Console output
> 2013-11-16 13:20:15,609 [queryBuilder] INFO route1
> - [queryBuilder] url:jdbc:oracle:thin:...
> Cannot create JDBC driver of class 'oracle.jdbc.driver.OracleDriver'
> for
> connect URL '{{datasource.stg.url}}'
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-properties-component-not-being-resolved-when-configuring-data-source-tp5743375.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: [email protected]
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen