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

  • SEARCH
  • Home
  • 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 7935123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:49:44+00:00 2026-06-03T21:49:44+00:00

I am using spring mvc3 and hibernate3. In my application i have a requirement

  • 0

I am using spring mvc3 and hibernate3. In my application i have a requirement to use a servlet.
In that servelet I have to call my DAO Layer. but when I am using following code in my servlet.

Session session = HibernateUtil.getSessionFactory().openSession();
public class HibernateUtil {
    private static final SessionFactory sessionFactory;
    static {
        try {
            sessionFactory = new Configuration().configure()
                    .buildSessionFactory();
        } catch (Throwable ex) {
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }

    public static SessionFactory getSessionFactory() {
        return sessionFactory;
    }
}

I am getting error org.hibernate.HibernateException: hibernate.cfg.xml not found.

Currently my xml file is in WEB-INF folder along with other configuration file.

All solutions are saying I need to keep it in src folder so automatically it will be fetched at runtime. but I am using spring mvc here.
So i am little bit confuse please help me how to solve it.

all other places where I am using controller its working fine.

enter image description here

I am using following entry in carpool-servlet.xml

following is my carpool-hibernate.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:p="http://www.springframework.org/schema/p" 
        xmlns:tx="http://www.springframework.org/schema/tx"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="
            http://www.springframework.org/schema/beans 
            http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
            http://www.springframework.org/schema/tx 
            http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context-3.0.xsd
            ">

    <context:property-placeholder location="/WEB-INF/dbproperties.properties" />

    <!-- Enable annotation style of managing transactions -->
    <tx:annotation-driven transaction-manager="transactionManager" />   

    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
                 p:dataSource-ref="dataSource"
                 p:configLocation="${hibernate.config}"
                 p:packagesToScan="store.custom.controllers">

                <property name="annotatedClasses">
        <list>
            <value>common.domain.Ride</value>
            <value>common.businessclass.PostAdRR</value>
        </list>
    </property>
                 </bean>

    <!-- Declare a datasource that has pooling capabilities-->   
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
                destroy-method="close"
                p:driverClass="${jdbc.driverClassName}"
                p:jdbcUrl="${jdbc.url}"
                p:user="${jdbc.username}"
                p:password="${jdbc.password}"
                p:acquireIncrement="5"
                p:idleConnectionTestPeriod="60"
                p:maxPoolSize="100"
                p:maxStatements="50"
                p:minPoolSize="10" />

    <!-- Declare a transaction manager-->
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" 
                p:sessionFactory-ref="sessionFactory" />

</beans>

following is my hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC

        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"

        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">


<hibernate-configuration>

  <session-factory>
    <!-- We're using MySQL database so the dialect needs to MySQL as well-->
    <property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
    <!-- Enable this to see the SQL statements in the logs-->
    <property name="show_sql">true</property>
    <!-- This will drop our existing database and re-create a new one.
            Existing data will be deleted! -->
<!-- <property name="hbm2ddl.auto">create</property>-->
  </session-factory>

</hibernate-configuration>

now how can I set my hibernate config.xml
Please help

  • 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-06-03T21:49:47+00:00Added an answer on June 3, 2026 at 9:49 pm

    Where is hibernate.config being set

    p:configLocation="${hibernate.config}"
    

    If you are using maven, you can move this file to src/main/resources then do classpath:hibernate.config.xml, otherwise if you’re not, move it within classpath under WEB-INF/classes as duffymo stated.

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

Sidebar

Related Questions

I am using the spring mvc3 in my applicatio,and in the dao layer I
We are currently building a mid-sized intranet application using MVC3. One requirement is the
I have problem with displaying error message in spring Application.i am using Spring MVC
I'm using Spring MVC 3.0 and Tomcat. I have a bean that has a
We have a Spring web application created using Spring MVC 3.0 In the same
i am creating a demo application using spring mvc 3.0.I have to apply the
I'm currently developing a multi-tiered application, using MVC3 and Spring.NET all of which is
Using Spring 2.5 tag library, I have an Integer value in a command form
Our application is developed using Spring framework. Is it good practice to check null
I'm using Spring, Spring Security, BlazeDS, Flex and spring-flex. I know that I can

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.