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 7558267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:19:38+00:00 2026-05-30T12:19:38+00:00

I am creating a simple application to learn Hibernate. I am using NetBeans IDE

  • 0

I am creating a simple application to learn Hibernate. I am using NetBeans IDE and I created a class in com.hibernate package. The class is defined as:

package com.hibernate;

import com.mahesh.entity.UserDetails; 

import org.hibernate.SessionFactory; 
import org.hibernate.cfg.Configuration;
import org.hibernate.classic.Session;

public class hibr {
    public static void main(String[] args) {
        UserDetails user = new UserDetails();
        user.setUserID(1);
        user.setUserName("Mahesh");

        SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
        Session session = sessionFactory.openSession();
        session.beginTransaction();
        session.save(user);
        session.getTransaction().commit();
    }
}

I have defined UserDetails class as:

package com.mahesh.entity;

import javax.persistence.Entity;
import javax.persistence.Id;

/**
 *
 * @author Mahesh
 */
@Entity
public class UserDetails {
    @Id
    private int userID;
    private String userName;

    public void setUserID(int userID) {
        this.userID = userID;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public int getUserID() {
        return userID;
    }

    public String getUserName() {
        return userName;
    }
}

I have defined a hibernate.cfg.xml file which is in src folder(default package)

This is the error generated by NetBeans IDE.

Feb 27, 2012 8:51:35 AM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml Feb 27, 2012
8:51:35 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml Exception in thread
“main” org.hibernate.HibernateException: /hibernate.cfg.xml not found
at
org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:147)
at
org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1405)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1427)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1414)
at com.hibernate.hibr.main(hibr.java:18) Java Result: 1

  • 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-30T12:19:40+00:00Added an answer on May 30, 2026 at 12:19 pm

    try

    new Configuration().configure(<your cfg file path>).buildSessionFactory();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a simple application using the MVC design pattern where my model
When I am creating a simple application for plist shown in below link: http://iosdevelopertips.com/data-file-management/reading-a-plist-into-an-nsarray.html
I am creating an simple android application in that created a notification. Now i
I am trying to learn MVC and nHibernate by creating a simple blog application.
I'm creating a simple drawing application using WPF. I've run into some strange behaviour
I'm creating a simple application using the Kohana PHP framework, just FYI. This is
I am creating simple blog web application using play framework and i want to
I am creating a simple application with Django. I realized that I am doing
Was creating a simple console application to do some prototyping and was shocked to
I am interested in creating a simple web application that will take in user

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.