Results 1 to 3 of 3

Thread: hibernate + spring

  1. #1
    Join Date
    Dec 2004
    Posts
    22

    Default 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. #2
    Join Date
    Aug 2004
    Location
    Roeselare, Belgium
    Posts
    16

    Default

    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)
    Pieter Coucke
    Onthoo.com

  3. #3
    Join Date
    Dec 2004
    Posts
    22

    Default

    Thanks pietercoucke,
    That solved the problem.


    Quote 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)

Similar Threads

  1. Replies: 5
    Last Post: Feb 3rd, 2009, 05:19 AM
  2. Replies: 3
    Last Post: Aug 16th, 2007, 12:10 PM
  3. A Spring Class Loader?
    By azzoti in forum Architecture
    Replies: 8
    Last Post: May 7th, 2005, 04:02 AM
  4. Replies: 14
    Last Post: Feb 21st, 2005, 05:41 PM
  5. Replies: 7
    Last Post: Aug 21st, 2004, 03:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •