PDA

View Full Version : Strange problem



eboix
04-10-2006, 11:29 AM
Though I've solved it, I'd like to know if this is a bug or it's just me:

I'm playing with AOP to intercept/cache the calls to my Dao layer. I have this object which creates my Dao:



<object id="DaoLineasTarget"
type="MACv2.Mac.Dao.DaoLineasSqlWrapper, MACv2"
factory-method="SqlWrapperFactory">
<property name="Connexio"><ref object="connexioSql"/></property>
<property name="log"><ref object="macLog"/></property>
</object>


In order to implement the cache via AOP, I've replaced this for:



<object id="LineasCaching"
type="MACv2.Mac.Dao.Interceptors.LineasCaching, MACv2">
<property name="log"><ref object="macLog"/></property>
</object>
<object id="DaoLineas" type="Spring.Aop.Framework.ProxyFactoryObject">
<property name="target">
<object type="MACv2.Mac.Dao.DaoLineasSqlWrapper, MACv2"
factory-method="SqlWrapperFactory">
<property name="Connexio"><ref object="connexioSql"/></property>
<property name="log"><ref object="macLog"/></property>
</object>
</property>
<property name="interceptorNames">
<list>
<value>LineasCaching</value>
</list>
</property>
</object>


Quite simple.

The problem is:

If the connection string is retrieved from Web.config:



<object name="connexioSql" type="System.Data.SqlClient.SqlConnection, System.Data">
<property name="ConnectionString"><value>$&#123;connection.string&#125;</value></property>
</object>


...Spring (well, .Net) throws the following exception:



PropertyAccessExceptionsException &#40;1 errors&#41;; nested PropertyAccessExceptions are&#58; &#91;Spring.Objects.MethodInvocationException&#58; Property 'ConnectionString' threw exception., Inner Exception&#58; System.ArgumentException&#58; Format of the initialization string does not conform to specification starting at index 0. at System.Data.Common.DBConnectionString.GetKeyValueP air&#40;Char&#91;&#93; connectionString, Int32 currentPosition, String& key, Char&#91;&#93; valuebuf, Int32& vallength, Boolean& isempty&#41; at System.Data.Common.DBConnectionString.ParseInterna l&#40;Char&#91;&#93; connectionString, UdlSupport checkForUdl, NameValuePair& keychain&#41; at System.Data.Common.DBConnectionString..ctor&#40;String connectionString, UdlSupport checkForUdl&#41; at System.Data.SqlClient.SqlConnectionString..ctor&#40;St ring connectionString&#41; at System.Data.SqlClient.SqlConnectionString.ParseStr ing&#40;String connectionString&#41; at System.Data.SqlClient.SqlConnection.set_Connection String&#40;String value&#41;&#93;


...whereas if I set the connection string directly, everthing works fine.

Regards,
Esteve

Bruno Baia
04-10-2006, 12:06 PM
Hi Esteve,

How is configured the PropertyPlaceholderConfigurer to retrieve the value of ${connection.string} ?
Can you show us how it looks like ?

It seems the placeholder is not replaced.


-Bruno

eboix
04-10-2006, 01:24 PM
Bruno,

Thanks for you fast reply.

I do not have the code here, but w/o applying the proxy, everything works fine, so the placeholder is set up.

I'll post later the details of the placeholder setup.

Regards,
Esteve