Announcement Announcement Module
Collapse
No announcement yet.
TypeMisMatch Exception when i use proxyTargetClass Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • TypeMisMatch Exception when i use proxyTargetClass

    The following configuration when i tried to use is throwing


    <bean id="test" name="com.base.MyAction"
    class="com.base.MyAction"
    singleton="false">
    </bean>

    <bean id="MyInterceptor" class="com.springaop.MyInterceptor"/>



    <bean id="proxyCreator" class="org.springframework.aop.framework.autoproxy .BeanNameAutoProxyCreator">

    <property name="proxyTargetClass">
    <value>true</value>
    </property>

    <property name="interceptorNames">
    <list>
    <ref bean="MyInterceptor" />
    </list>
    </property>

    <property name="beanNames">
    <list>
    <value>test</value>
    </list>
    </property>

    </bean>



    Stack trace:


    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean wit
    h name 'proxyCreator' defined in class path resource [SpringConfig.xml]: Error s
    etting property values; nested exception is org.springframework.beans.PropertyAccessExceptions Exception: PropertyAccessExceptionsException (1 errors); nested propertyAccessExceptions are: [org.springframework.beans.TypeMismatchException: Failed to convert property value of type [com.springaop.MyInterceptor] to required type [java.lang.String] for property 'interceptorNames[0]']
    PropertyAccessExceptionsException (1 errors)
    org.springframework.beans.TypeMismatchException: Failed to convert property valu
    e of type [com.springaop.Mynterceptor] to required type [java.l
    ang.String] for property 'interceptorNames[0]'
    at org.springframework.beans.BeanWrapperImpl.doTypeCo nversionIfNecessary
    (BeanWrapperImpl.java:942)
    at org.springframework.beans.BeanWrapperImpl.doTypeCo nversionIfNecessary
    (BeanWrapperImpl.java:907)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrappe
    rImpl.java:711)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrappe
    rImpl.java:617)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrappe
    rImpl.java:758)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValues(BeanWrapp
    erImpl.java:785)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValues(BeanWrapp
    erImpl.java:774)


    I am not able to find where exaclty .....i missed some configuration...


    Thanks

    TOM

  • #2
    The problem is here:

    <property name="interceptorNames">
    <list>
    <ref bean="MyInterceptor" />
    </list>
    As its name implies, the interceptorNames property takes as values bean names of interceptors, not bean references. Replace the <ref> element with a <value> element. This is documented in the reference manual (AOP chapter).

    Comment

    Working...
    X