Announcement Announcement Module
Collapse
No announcement yet.
hibernate + spring Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • hibernate + spring

    I am trying to use spring with hibernate.cfg.xml and am getting the following error


    org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.util.ArrayList] to required type [net.sf.hibernate.SessionFactory] for property 'sessionFactory'


    I am including the mapping file and a detailed list of the exception.

    Can some one help me figure out what is going on..

    Thanks
    Kevin

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>
    <!--
    <bean id="jndiTemplate"
    class="org.springframework.jndi.JndiTemplate">
    <constructor-arg>
    <props>
    <prop key="java.naming.factory.initial">org.jnp.interfac es.NamingContextFactory</prop>
    <prop key="java.naming.provider.url">jnp://localhost:1099</prop>
    <prop key="java.naming.factory.url.pkgs">org.jboss.namin g:org.jnp.interfaces</prop>
    </props>
    </constructor-arg>
    </bean>

    <bean id="customerEjb"
    class="org.springframework.ejb.access.SimpleRemote StatelessSessionProxyFactoryBean">
    <property name="jndiTemplate"><ref bean="jndiTemplate"/></property>
    <property name="jndiName">
    <value>ejb/Customer</value>
    </property>
    <property name="businessInterface">
    <value>com.sf.intf.ICustomer</value>
    </property>
    </bean>
    -->
    <bean id="customerBeanProxy" class="org.springframework.aop.framework.ProxyFact oryBean">
    <property name="singleton"><value>false</value></property>
    <property name="proxyTargetClass"><value>true</value></property>
    <property name="proxyInterfaces">
    <value>com.sf.intf.ICustomer</value>
    </property>

    <property name="interceptorNames">
    <list>
    <value>customerImpl</value>
    </list>
    </property>
    </bean>

    <bean id="mySessionFactory" class="org.springframework.orm.hibernate.LocalSess ionFactoryBean">
    <property name="configLocation"><value>hibernate.cfg.xml</value></property>
    </bean>

    <bean id="customerImpl" class="com.sf.bean.CustomerImpl" singleton="false">
    <property name="sessionFactory">
    <list>
    <value>mySessionFactory</value>
    </list>
    </property>
    </bean>


    </beans>








    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'customerBeanProxy': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'customerImpl' defined in class path resource [spring-config-client.xml]: Error setting 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 [java.util.ArrayList] to required type [net.sf.hibernate.SessionFactory] for property 'sessionFactory']
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'customerImpl' defined in class path resource [spring-config-client.xml]: Error setting 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 [java.util.ArrayList] to required type [net.sf.hibernate.SessionFactory] for property 'sessionFactory']
    PropertyAccessExceptionsException (1 errors)
    org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.util.ArrayList] to required type [net.sf.hibernate.SessionFactory] for property 'sessionFactory'
    at org.springframework.beans.BeanWrapperImpl.doTypeCo nversionIfNecessary(BeanWrapperImpl.java:942)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:711)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:617)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:758)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValues(BeanWrapperImpl.java:785)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValues(BeanWrapperImpl.java:774)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:784)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:601)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:258)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:193)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:253)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:163)
    at org.springframework.aop.framework.ProxyFactoryBean .freshTargetSource(ProxyFactoryBean.java:443)
    at org.springframework.aop.framework.ProxyFactoryBean .newPrototypeInstance(ProxyFactoryBean.java:253)
    at org.springframework.aop.framework.ProxyFactoryBean .getObject(ProxyFactoryBean.java:213)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getObjectForSharedInstance(AbstractBea nFactory.java:790)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:204)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:163)
    at org.springframework.context.support.AbstractApplic ationContext.getBean(AbstractApplicationContext.ja va:476)
    at com.sf.test.CustomerTest.main(CustomerTest.java:41 )

  • #2
    org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.util.ArrayList] to required type [net.sf.hibernate.SessionFactory] for property 'sessionFactory'
    Use

    Code:
    <bean id="customerImpl" class="com.sf.bean.CustomerImpl" singleton="false"> 
    <property name="sessionFactory"> 
    <ref bean="mySessionFactory"/>
    </property> 
    </bean>
    (without the <list> element)

    Comment


    • #3
      Thanks pietercoucke,
      That solved the problem.


      Originally posted by pietercoucke
      org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.util.ArrayList] to required type [net.sf.hibernate.SessionFactory] for property 'sessionFactory'
      Use

      Code:
      <bean id="customerImpl" class="com.sf.bean.CustomerImpl" singleton="false"> 
      <property name="sessionFactory"> 
      <ref bean="mySessionFactory"/>
      </property> 
      </bean>
      (without the <list> element)

      Comment

      Working...
      X