Hi,

I'm trying to replace a placeholder in my xml spring configuration file. In the manual I read about PropertyPlaceholderConfigurer but allways with XMLBeanFactory. Documention says that should use ApplicationContext in a J2EE environment so I tried the following:

Code:
...
ClassPathXmlApplicationContext appctx = new ClassPathXmlApplicationContext("springconfig.xml");
PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer();
Properties p = new Properties();
p.setProperty("jdbc.tnsname", "SOMENAME");
cfg.setProperties(p);
cfg.postProcessBeanFactory(appctx.getBeanFactory());
appctx.refresh();
...
Relevant part in springconfig.xml locks like

Code:
...
<bean id="DS_GASX" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
    <property name="url" value="jdbc:oracle:oci8:@${jdbc.tnsname}" />
    <property name="username" value="ABC" />
    <property name="password" value="XYZ" />
</bean>
...
<bean id="SF_HIBERNATE" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="DS_GASX" />
...
After
Code:
ClassPathXmlApplicationContext appctx = new ClassPathXmlApplicationContext("springconfig.xml");
Spring is trying to initialize Hibernate. A JDBC Exception is throws because the placeholder is still there and there is no TNS entry with this name.

After
Code:
cfg.postProcessBeanFactory(appctx.getBeanFactory());
I see some output in the logs saying "Resolved placeholder 'jdbc.tnsname' to value [SOMENAME]". After appctx.refresh() the initialization of hibernate still fails with the same JDBC TNS error. I tried it with appctx.refresh() and without. Everytime the same. I debugged a little in LocalDataSourceConnectionProvider and saw that the URL in the Connection still has the placeholder.

What is wrong? Is there an other way to do this? I can't use PropertyOverrideConfigurer because I dont have the needed propertie value there.

Tanks in advance.
Alex