PDA

View Full Version : Problem configuring transaction proxy


merry_ploughboy
07-24-2007, 10:36 AM
Hi,

I'm trying to use spring.net (1.1M2) and nhibernate (1.2) and I'm having problems configuring the TransactionProxy.

using: sqlServer2005, .net3.0


my config:
<object id="TxProxyConfigurationTemplate" abstract="true"
type="Spring.Transaction.Interceptor.TransactionProxyFac toryObject, Spring.Data">

<property name="PlatformTransactionManager" ref="HibernateTransactionManager"/>
<property name="TransactionAttributes">
<name-values>
<!-- Add common methods across your services here -->
<add key="Save*" value="PROPAGATION_REQUIRED"/>
<!--
<add key="Delete*" value="PROPAGATION_REQUIRED"/>
-->
</name-values>
</property>
</object>

<object id="AuditTrailServiceTarget" type="Com.XXX.BusinessTier.Impl.AuditTrailServiceImpl, Com.XXX.BusinessTier">
<property name="AuditTrailRecordDao" ref="AuditTrailRecordDao"/>
<property name="TransactionTypeDao" ref="TransactionTypeDao"/>
<property name="TransactionAttributeDao" ref="TransactionAttributeDao" />
<property name="AuditTrailRecordDetailDao" ref="AuditTrailRecordDetailDao"/>
<property name="TransactionTypes">
<dictionary key-type="String" value-type="String">
<entry>
<key>
<value>CREATE_AD_USER</value>
</key>
<value>1</value>
</entry>
<entry>
<key>
<value>ASSIGN_AD_USER_TO_GROUP</value>
</key>
<value>2</value>
</entry>
</dictionary>
</property>
</object>

<object id="AuditTrailService" parent="TxProxyConfigurationTemplate">
<!-- Note: would likely use an anonymous inner object instead of a reference -->
<!-- to ensure that no one can access an unadvised object -->
<property name="Target" ref="AuditTrailServiceTarget"/>
</object>

the error thrown:
[PropertyAccessExceptionsException: PropertyAccessExceptionsException (1 errors); nested PropertyAccessExceptions are:
[Spring.Objects.TypeMismatchException: Cannot convert property value of type [CompositionAopProxy_9883bace9bd840a5b1eca0ce4624fd a0] to required type [Com.Voestalpine.Cat.Admin.BusinessTier.Impl.AuditT railServiceImpl] for property 'AuditTrailService'., Inner Exception: Spring.Objects.TypeMismatchException: Cannot convert property value of type [CompositionAopProxy_9883bace9bd840a5b1eca0ce4624fd a0] to required type [Com.Voestalpine.Cat.Admin.BusinessTier.Impl.AuditT railServiceImpl] for property 'AuditTrailService'.
bei Spring.Util.ConversionUtils.ConvertValueIfNecessar y(Type requiredType, Object newValue, String propertyName)]]
Spring.Objects.ObjectWrapper.SetPropertyValues(IPr opertyValues propertyValues, Boolean ignoreUnknown) +948
Spring.Objects.ObjectWrapper.SetPropertyValues(IPr opertyValues pvs) +31
Spring.Objects.Factory.Support.AbstractAutowireCap ableObjectFactory.ApplyPropertyValues(String name, RootObjectDefinition definition, IObjectWrapper wrapper, IPropertyValues properties) +392

[ObjectCreationException: Error creating object with name 'UserService' defined in 'file [C:\projects\CAT\com.voestalpine.cat.admin\com.voes talpine.cat.admin\Config\spring-services.xml]' : Error setting property values: PropertyAccessExceptionsException (1 errors); nested PropertyAccessExceptions are:
[Spring.Objects.TypeMismatchException: Cannot convert property value of type [CompositionAopProxy_9883bace9bd840a5b1eca0ce4624fd a0] to required type [Com.Voestalpine.Cat.Admin.BusinessTier.Impl.AuditT railServiceImpl] for property 'AuditTrailService'., Inner Exception: Spring.Objects.TypeMismatchException: Cannot convert property value of type [CompositionAopProxy_9883bace9bd840a5b1eca0ce4624fd a0] to required type [Com.Voestalpine.Cat.Admin.BusinessTier.Impl.AuditT railServiceImpl] for property 'AuditTrailService'.
bei Spring.Util.ConversionUtils.ConvertValueIfNecessar y(Type requiredType, Object newValue, String propertyName)]]
Spring.Objects.Factory.Support.AbstractAutowireCap ableObjectFactory.ApplyPropertyValues(String name, RootObjectDefinition definition, IObjectWrapper wrapper, IPropertyValues properties) +492
Spring.Objects.Factory.Support.AbstractAutowireCap ableObjectFactory.PopulateObject(String name, RootObjectDefinition definition, IObjectWrapper wrapper) +308
Spring.Objects.Factory.Support.AbstractAutowireCap ableObjectFactory.ConfigureObject(String name, RootObjectDefinition definition, IObjectWrapper wrapper) +146
Spring.Objects.Factory.Support.AbstractAutowireCap ableObjectFactory.CreateObject(String name, RootObjectDefinition definition, Object[] arguments, Boolean allowEagerCaching) +920
Spring.Objects.Factory.Support.WebObjectFactory.Cr eateAndCacheSingletonInstance(String objectName, RootObjectDefinition objectDefinition, Object[] arguments) +186
Spring.Objects.Factory.Support.AbstractObjectFacto ry.GetObject(String name, Type requiredType, Object[] arguments) +622
Spring.Objects.Factory.Support.AbstractObjectFacto ry.GetObject(String name, Object[] arguments) +64
Spring.Objects.Factory.Support.AbstractObjectFacto ry.GetObject(String name) +40
Spring.Objects.Factory.Support.DefaultListableObje ctFactory.PreInstantiateSingletons() +632
Spring.Context.Support.AbstractApplicationContext. Refresh() +877
Spring.Context.Support.WebApplicationContext..ctor (String name, Boolean caseSensitive, IApplicationContext parentContext, String[] configurationLocations) +87
Spring.Context.Support.WebApplicationContext..ctor (String name, Boolean caseSensitive, String[] configurationLocations) +41

I've tried almost every configuration in the documentation and I either end up with the error above, or with a transaction that is not commited to the database.

Can someone shed light on this issue for me?
thx
mp

merry_ploughboy
07-24-2007, 12:02 PM
oh, by the way, the exception occurs only when I try to inject the proxied object into another object like so:

<object id="UserService" type="Com.XXX.BusinessTier.Impl.UserServiceImpl">
<property name="AuditTrailService" ref="AuditTrailService"/>
</object>

merry_ploughboy
07-24-2007, 01:10 PM
using the configuration via the transaction namespace result in the same error:


Spring.Objects.Factory.ObjectCreationException : Error creating object with name 'UserService' defined in 'file [C:\projects\CAT\com.voestalpine.cat.admin\com.voes talpine.cat.admin\Config\spring-services.xml]' : Error setting property values: PropertyAccessExceptionsException (1 errors); nested PropertyAccessExceptions are:
[Spring.Objects.TypeMismatchException: Cannot convert property value of type [CompositionAopProxy_4f15e17aa42b46579cfea38a29038c c4] to required type [Com.Voestalpine.Cat.Admin.BusinessTier.Impl.AuditT railServiceImpl] for property 'AuditTrailService'., Inner Exception: Spring.Objects.TypeMismatchException: Cannot convert property value of type [CompositionAopProxy_4f15e17aa42b46579cfea38a29038c c4] to required type [Com.Voestalpine.Cat.Admin.BusinessTier.Impl.AuditT railServiceImpl] for property 'AuditTrailService'.
bei Spring.Util.ConversionUtils.ConvertValueIfNecessar y(Type requiredType, Object newValue, String propertyName)]
----> Spring.Objects.PropertyAccessExceptionsException : PropertyAccessExceptionsException (1 errors); nested PropertyAccessExceptions are:
[Spring.Objects.TypeMismatchException: Cannot convert property value of type [CompositionAopProxy_4f15e17aa42b46579cfea38a29038c c4] to required type [Com.Voestalpine.Cat.Admin.BusinessTier.Impl.AuditT railServiceImpl] for property 'AuditTrailService'., Inner Exception: Spring.Objects.TypeMismatchException: Cannot convert property value of type [CompositionAopProxy_4f15e17aa42b46579cfea38a29038c c4] to required type [Com.Voestalpine.Cat.Admin.BusinessTier.Impl.AuditT railServiceImpl] for property 'AuditTrailService'.
bei Spring.Util.ConversionUtils.ConvertValueIfNecessar y(Type requiredType, Object newValue, String propertyName)]

my code:
<object id="MethodPointCut"
type="Spring.Aop.Support.SdkRegularExpressionMethodPoint cut, Spring.Aop">
<property name="patterns">
<list>
<value>Com.XXX.BusinessTier.Impl.*</value>
</list>
</property>
</object>

<tx:advice id="txAdvice" transaction-manager="HibernateTransactionManager">
<!-- the transactional semantics... -->
<tx:attributes>
<tx:method name="Save*" propagation="Required"/>
<!-- all methods starting with 'get' are read-only -->
<tx:method name="Get*" read-only="true"/>
<!-- other methods use the default transaction settings (see below) -->
<tx:method name="*"/>
</tx:attributes>
</tx:advice>

<aop:config>
<aop:advisor pointcut-ref="MethodPointCut" advice-ref="txAdvice"/>
</aop:config>

merry_ploughboy
07-24-2007, 02:29 PM
ok... i got it. I ashamedly admit that I had the AuditTrailServiceImpl and not the IAuditTrailService declared as a property...

shame on me.:rolleyes:

Mark Pollack
07-25-2007, 02:28 PM
Hi,
No worries, glad you figured it out!
Cheers,
Mark