Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6801241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:04:33+00:00 2026-05-26T19:04:33+00:00

This is a spring mvc application using IntelliJ. I’m getting this error: org.springframework.orm.hibernate3.HibernateSystemException: Unknown

  • 0

This is a spring mvc application using IntelliJ.

I’m getting this error:

org.springframework.orm.hibernate3.HibernateSystemException: Unknown entity: com.testproj1.core.model.User; nested exception is org.hibernate.MappingException: Unknown entity: com.testproj1.core.model.User
    org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:679)
    org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
    org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411)
    org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
    org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:512)
    org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:506)
    com.testproj1.core.doa.UserDaoImpl.get(UserDaoImpl.java:17)
    com.testproj1.core.service.UserServiceImpl.getUser(UserServiceImpl.java:22)
    com.testproj1.web.controllers.HomeController.index(HomeController.java:19)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
    org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
    org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

org.hibernate.MappingException: Unknown entity: com.testproj1.core.model.User
    org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:701)
    org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:92)
    org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1080)
    org.hibernate.impl.SessionImpl.get(SessionImpl.java:997)
    org.hibernate.impl.SessionImpl.get(SessionImpl.java:990)
    org.springframework.orm.hibernate3.HibernateTemplate$1.doInHibernate(HibernateTemplate.java:519)
    org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
    org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
    org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:512)
    org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:506)
    com.testproj1.core.doa.UserDaoImpl.get(UserDaoImpl.java:17)
    com.testproj1.core.service.UserServiceImpl.getUser(UserServiceImpl.java:22)
    com.testproj1.web.controllers.HomeController.index(HomeController.java:19)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
    org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
    org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
testproj1

Here is my setup, hibernate.cfg.xml:

<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
    <session-factory>

        <mapping package="com.testproj1.core.model"/>

        <mapping class="com.testproj1.core.model.User"/>


    </session-factory>

</hibernate-configuration>

My servlet-context.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->

    <!-- Scans within the base package of the application for @Components to configure as beans -->
    <!-- @Controller, @Service, @Configuration, etc. -->
    <context:component-scan base-package="com.testproj1" />

    <!-- Enables the Spring MVC @Controller programming model -->
    <mvc:annotation-driven />



     <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://localhost/testproj1"/>
        <property name="username" value="root"/>
        <property name="password" value="123"/>
        <property name="maxActive" value="100"/>
        <property name="maxIdle" value="30"/>
        <property name="maxWait" value="1000"/>
        <property name="defaultAutoCommit" value="true"/>
        <property name="removeAbandoned" value="true"/>
        <property name="removeAbandonedTimeout" value="60"/>
    </bean>


    <!-- Hibernate SessionFactory -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <!--<property name="packagesToScan" value="com.testproj1.core.model"/>-->
        <property name="configLocation" value="/WEB-INF/config/hibernate.cfg.xml"/>
        <property name="hibernateProperties">
            <value>
                hibernate.dialect=org.hibernate.dialect.MySQLDialect
                hibernate.query.substitutions=true 'Y', false 'N'
                hibernate.show_sql=true
            </value>
        </property>
        <property name="annotatedClasses">
            <list>
                <value>com.testproj1.core.model.User</value>
            </list>
        </property>
    </bean>

    <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->


    <bean id="userDao" class="com.testproj1.core.doa.UserDaoImpl">
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>

</beans>

My controller:

public class HomeController {

    @Autowired
    private UserService userService;

    @RequestMapping("/")
    public String index() {
        System.out.println("hello, world!");

        User user = userService.getUser(1);

        System.out.println("Username is: " + user.getUsername());

        return "WEB-INF/views/home.jsp";
    }
}

UserServiceImpl:

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserDao userDao;

    public User getUser(int id) {
        return userDao.get(id);
    }

}

UserDaoImpl:

public class UserDaoImpl extends GenericDaoImpl<User, Integer> implements UserDao {



    public User get(int id) {
        User user = super.getHibernateTemplate().get(User.class, id); 


        return user;
    }

    public void addUser(User user)
    {
        super.getHibernateTemplate().save(user);
    }

}

User model:

package com.testproj1.core.model;

import org.hibernate.annotations.Entity;


import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name="users")
public class User {

    protected Integer id;
    protected String user_name;

    @Id
    public Integer getId() {
        return id;
    }

    @Column
    public String getUsername() {
        return user_name;
    }


    public void setId(Integer id) {
        this.id = id;
    }

    public void setUsername(String user_name) {
        this.user_name = user_name;
    }

}

Now it is obvious it is not picking up my User model for some reason.

What I’m confused is, I did set it so spring would automatically scan the jar for this (at least I think) in the servlet-context.xml in the component-scan tag.

I also have the annotatedClasses property in the sessionFactory bean tag.

I commented out the packagesToScan in the sessionFactory bean tag as I was reading that this error could be because of circular references which I think means it is being wired up to many times?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:04:34+00:00Added an answer on May 26, 2026 at 7:04 pm

    Use javax.persistence.Entity rather than org.hibernate.annotations.Entity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I keep getting this HttpMediaTypeNotAcceptableException error for AJAX requests when using with Spring MVC
I notice that there is getWebApplicationContext in org.springframework.web.servlet.mvc.AbstractController . This means that spring programmers
I'm trying to make this 2-player web game application using Spring MVC. I have
In the context of an MVC application (using Spring MVC in this case), given
This is an example of using ThrowawayController in Spring MVC: public class DisplayCourseController implements
I have this web application using Spring Web Flow framework. In my main page
I have a spring MVC application using JSP as my view technologies with Jquery
I'm trying build my application using REST and Spring MVC. For some entities I
in a Spring MVC 2.5 application i'm using a spring <form:form> component and in
I am using Jboss and Netbeans to create Spring MVC web application on windows.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.