Monday, July 14, 2008

PropertyPlaceholderConfigurer.ignoreUnresolvablePlaceholders and my precious one hour

To speed up my prototyping process, I decided to use Mule to takecare of the integration of my core code with the persistence layer for me. Yes, basically I am lazy to write all the polling, updating, etc. This did not turn out good as I was stupidly assuming a startup problem a Mule issue and tried to fix it in the past 1 hour.

So what was it about?

I have a Mule configuration and also a Spring beans configuration which is used to configure datasource. PropertyPlaceholderConfigurer is also defined in the Spring configuration to read a file and those properties will be filled into the datasource settings, e.g.

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName">
<property name="url">
<property name="username">
<property name="password">

Great, unit test goes easier now. Not yet.

I have this JDBC query settings in my Mule configuration:

<jdbc:connector name="jdbcConnector" dataSource-ref="dataSource" pollingFrequency="5000">
<jdbc:query key="getSurrogateById" value="SELECT * FROM surrogate WHERE surrogateId=${header:test}" />

Tried to start Mule, but it failed with this error:

[07-15 00:47:34] ERROR AbstractConfigurationBuilder [main]: Configuration with "org.mule.config.spring.SpringXmlConfigurationBuilder" failed.
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'jdbcConnector' defined in null: Could not resolve placeholder 'header:test'
at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(
at org.mule.config.spring.MuleApplicationContext.<init>(</init>

Changing the Mule version didn't help (something stupid that I did), until I uncommented PropertyPlaceholderConfigurer, Mule was able to start. That gave me the clue to look into the class (which I didn't have to as the stacktrace was obvious enough) to find out the ignoreUnresolvablePlaceholders property.


- yc, finished ranting

No comments: