PDA

View Full Version : Strange problem


eboix
04-10-2006, 12:29 PM
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>${connection.string}</value></property>
</object>


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


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


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

Regards,
Esteve

Bruno Baia
04-10-2006, 01: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, 02: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