Announcement Announcement Module
Collapse
No announcement yet.
Spring - Hibernate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring - Hibernate

    Hi everybody,
    I'm trying to follow a tutoriel about hibernate integration in a spring project. with a big a shame, i have a probleme somewhere and i d be very happy that you help me to find in out

    here is my spring configuration file
    <beans>
    <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
    <property name="url" value="jdbc:mysql://localhost:3306/tp"/>
    <property name="username" value="root"/>
    <property name="password" value="root"/>
    </bean>

    <bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
    <property name="dataSource" ref="myDataSource"/>
    <property name="mappingResources">
    <list>
    <value>tp/spring/model/person.hbm.xml</value>
    </list>
    </property>
    <property name="hibernateProperties">
    <value>
    hibernate.format_sql=true
    hibernate.dialect=org.hibernate.dialect.MySQLDiale ct
    </value>
    </property>

    </bean>

    <bean id="personneDao" class="tp.spring.dao.PersonDaoImp">
    <property name="sessionFactory" ref="mySessionFactory"/>
    </bean>
    and this is PersonDapImp class:
    public class PersonDaoImp
    {
    private HibernateTemplate hibernateTemplate;
    private SessionFactory sessionFactory;
    public void setSessionFactory(SessionFactory sessionFactory) {
    hibernateTemplate = new HibernateTemplate(sessionFactory);
    }

    public List<Person> getAllPersons() throws DataException {
    return this.sessionFactory.getCurrentSession().createQuer y("from Person") .list();
    }
    }
    and the Test class:
    beanFactory = new XmlBeanFactory(new ClassPathResource("ApplicationContexte.xml"));
    List<Person> list = (List<Person>)beanFactory.getBean("personneDao");
    System.out.println("list size: "+list.size());
    Fnnally this is the errors accured
    Exception in thread "main" org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'personneDao' defined in class path resource [ApplicationContexte.xml]: Cannot resolve reference to bean 'mySessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.CannotLoadBeanCl assException: Error loading class [org.springframework.orm.hibernate3.LocalSessionFac toryBean] for bean with name 'mySessionFactory' defined in class path resource [ApplicationContexte.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/springframework/dao/support/PersistenceExceptionTranslator
    Caused by: org.springframework.beans.factory.CannotLoadBeanCl assException: Error loading class [org.springframework.orm.hibernate3.LocalSessionFac toryBean] for bean with name 'mySessionFactory' defined in class path resource [ApplicationContexte.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/springframework/dao/support/PersistenceExceptionTranslator
    Caused by: java.lang.NoClassDefFoundError: org/springframework/dao/support/PersistenceExceptionTranslator
    at java.lang.ClassLoader.defineClass1(Native Method)
    thanks for help
Working...
X