R – Spring + Hibernate bean declaration error

hibernatespring

  <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mappingResources">
  <list>
    <value>product.hbm.xml</value>
  </list>
</property>
<property name="hibernateProperties">
  <value>
    hibernate.dialect=org.hibernate.dialect.HSQLDialect
  </value>
</property>

I have this configuration in my applicationContext.xml file

However I get this error when I try to run my application:

Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sessionFactory' defined in
ServletContext resource [/WEB-INF/applicationContext.xml]
Instantiation of bean failed; nested exception is
org.springframework.beans.BeanInstantiationException: Could not
instantiate bean class
[org.springframework.orm.hibernate3.LocalSessionFactoryBean]:
Constructor threw exception; nested exception is
java.lang.NoClassDefFoundError: org/dom4j/DocumentException

So it seems like it's not recognizing the class LocalSessionFactoryBean. However I when type, import org.springframework.orm.hibernate3.LocalSessionFactoryBean;, eclipse doesn't complain.

Does anybody have an idea why this is happening?

Best Answer

I believe the key is this line:

nested exception is java.lang.NoClassDefFoundError:

org/dom4j/DocumentException

I would check the classpath to ensure that dom4j is there.

Related Topic