Announcement Announcement Module
Collapse
No announcement yet.
org.springframework.beans.TypeMismatchException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • org.springframework.beans.TypeMismatchException

    Hi,

    I am trying to use "auto-proxy" feature. I have a DAO class which implements an interface and extends JdbcTemplate like follows

    Code:
    public interface ClientDAO {
    }
    
    public class ClientDAOImpl extends JdbcTemplate
    implements ClientDAO
    This class is configured in applicationContext.xml as below
    Code:
    <bean id="clientDAO" class="com.myapp.dao.ClientDAOImpl">
    		<property name="dataSource">
    			<ref bean="dataSource" />
    		</property>
    			</bean>
    I am trying to intercept calls to this class using BeanNameAutoProxyCreator as below
    Code:
    <bean name="logAutoProxy" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
    	   <property name="beanNames">
    		<value>*DAO</value>
    	   </property>
    	   <property name="interceptorNames">
        	 	<list>
            	 <value>logInterceptor</value>
    	     	</list>
    	   </property>
    	</bean>
    .

    But when i deploy my application and restart the server I am getting following exception
    Code:
    org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy9] to required type [com.myapp.dao..ClientDAOImpl] for property 'clientDAO'
    	at org.springframework.beans.BeanWrapperImpl.doTypeConversionIfNecessary(BeanWrapperImpl.java:1099)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:844)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:734)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:886)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:913)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:902)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:967)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:768)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:330)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:176)
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:105)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:957)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:768)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:330)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:176)
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:105)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:957)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:768)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:330)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:275)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:317)
    	at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:134)
    	at org.springframework.web.struts.ContextLoaderPlugIn.createWebApplicationContext(ContextLoaderPlugIn.java:352)
    	at org.springframework.web.struts.ContextLoaderPlugIn.initWebApplicationContext(ContextLoaderPlugIn.java:295)
    	at org.springframework.web.struts.ContextLoaderPlugIn.init(ContextLoaderPlugIn.java:224)
    	at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:842)
    	at org.apache.struts.action.ActionServlet.init(ActionServlet.java:335)
    	at javax.servlet.GenericServlet.init(GenericServlet.java:258)
    Whats the issue? Can anybody plz help?

  • #2
    It seems that some other bean (one that is not shown) has a property of the ClientDAOImpl type. Since the proxy created implements the ClientDAO interface, but does not extend ClientDAOImpl, you get an exception.

    Check if any of the other beans have a method of the form: setClientDAO(ClientDAOImpl).

    -Ramnivas

    Comment

    Working...
    X