This week's book giveaway is in the OCP forum.
We're giving away four copies of OCP Java SE 8 Programmer II Exam Study Guide and have Kathy Sierra, Bert Bates, & Elizabeth Robson on-line!
See this thread for details.
Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Error creating bean with name 'sessionFactory'  RSS feed

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

i have big problem with Spring 2.5, Spring MVC, Hibernate, Hibernate Annotations 3.3.0.GA and tomcat 6.0.14, acegi 1.0.6 (and ehcache 1.3.0)

in applicationContext-resources.xml :

<?xml version="1.0" encoding="UTF-8"?>

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
<property name="driverClassName" value="org.postgresql.Driver" />
<property name="url" value="jdbc ostgresql://localhost:5432/xxx" />
<property name="username" value="xxx" />
<property name="password" value="iwtbxfm" />
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotati on.AnnotationSessionFactoryBean">
<property name="hibernateProperties">
<prop key="hibernate.dialect">org.hibernate.dialect.Post greSQLDialect</prop>
<prop key="hibernate.query.substitutions">true 'T', false 'F'</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.hibernate.generate_statistics">true </prop>

<prop key="hibernate.cache.use_second_level_cache">false </prop>

<prop key="hibernate.cache.provider_configuration_file_r esource_path">classpath:/ehcache.xml</prop>
<property name="dataSource" ref="dataSource"/>
<property name="configLocation" value="classpath:/hibernate.cfg.xml"/>


<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
<mapping class=""/>

BUT after build of project a have this error:

INFO: Initializing Spring root WebApplicationContext
9.1.2008 18:43:15 org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListe ner
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext-resources.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Unable to load class declared as <mapping class=""/> in the configuration:
at AutowireCapableBeanFactory.initializeBean(Abstract
at AutowireCapableBeanFactory.doCreateBean(AbstractAu
at AutowireCapableBeanFactory$
at Method)
at AutowireCapableBeanFactory.createBean(AbstractAuto
at BeanFactory$1.getObject( 51)
at ingletonBeanRegistry.getSingleton(DefaultSingleton
at BeanFactory.getBean(
at BeanFactory.getBean(
at istableBeanFactory.preInstantiateSingletons(Defaul
at ationContext.finishBeanFactoryInitialization(Abstr



import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.CascadeType;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;

@Entity @Table(name="carrier")

public class Carrier extends BaseObject {

@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seq_carrier")
private Long id;

private String name = null;

private String address = null;

public Carrier() {}

public Long getId() {
return id;

public void setId(Long id) { = id;

public String getName() {
return name;

public void setName(String name) { = name;

public String getAddress() {
return address;

public void setAddress(String address){
this.address = address;

public boolean equals(Object o) {
if (this == o) {
return true;
if (!(o instanceof Carrier)) {
return false;

final Carrier carrier = (Carrier) o;

return !(name != null ? !name.equals(carrier.getName()) : carrier.getName() != null);


public int hashCode() {
return (name != null ? name.hashCode() : 0);

public String toString() {
return null;

in web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" version="2.4" xmlns="" xmlns:xsi="" xsi:schemaLocation="">


<!-- Context Configuration locations for Spring XML files -->

<servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>


<filter-name>Acegi Filter Chain Proxy</filter-name>

<filter-name>Acegi Filter Chain Proxy</filter-name>

org.springframework.web.context.ContextLoaderListe ner



please, where is the problem ?


Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Make sure you hava all the jars available in your lib folder

Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where you are declaring your bean "SessionFactory" there is a space while defining the class make sure you spell word correctly.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!