Hibernate basic configuration in Spring 3 project - Class not found exception

I'm trying to set up Hibernate 3.6 in my existing Spring 3 MVC + Spring 3 security project. Nevertheless I keep getting java.lang.ClassNotFoundException in my HibernateUtil class - line with return new Configuration().configure().buildSessionFactory();

My project structure looks like this:


<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        <property name="hibernate.bytecode.use_reflection_optimizer">false</property>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.password">password</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3049/test</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="show_sql">true</property>
        <mapping resource="./DBUser.hbm.xml"></mapping>


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    <class name="../src/main/java/user/DBUser" table="DBUSER">
        <id name="userId" type="int">
            <column name="USER_ID" precision="5" scale="0" />
            <generator class="assigned" />
        <property name="username" type="string">
            <column name="USERNAME" length="20" not-null="true" />
        <property name="createdBy" type="string">
            <column name="CREATED_BY" length="20" not-null="true" />
        <property name="createdDate" type="date">
            <column name="CREATED_DATE" length="7" not-null="true" />

And a relevant part of the pom.xml file:

<!-- Hibernate + MySQL -->


EDIT: I've pasted here the stack trace. It was too long to put it right here, because it would make this post confused.

I'd be really glad, if someone could help me with setting up this thing, because I've got no idea, why it can't find that class.


It looks like you are missing the javaassist library. Download the javaassist jar and add it to your classpath.

Your class name should be the package path to the Hibernate POJO in DBUser.hbm.xml, e.g:


And your mapping resource does not need ./ in the path.

Need Your Help

unspecified function parameter

c++ c++03

In GManNickG's answer he used the notation:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.