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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:30:49+00:00 2026-06-09T23:30:49+00:00

Im new in hebirnate. Try execute example code. public class HibernateUtil { private static

  • 0

Im new in hebirnate. Try execute example code.

public class HibernateUtil {

private static final SessionFactory sessionFactory;

static {
    try {
        // Create the SessionFactory
        sessionFactory = new Configuration().configure().buildSessionFactory();
    } catch (HibernateException ex) {
        throw new RuntimeException("Configuration problem: " + ex.getMessage(), ex);
    }
}

public static final ThreadLocal session = new ThreadLocal();

public static Session currentSession() throws HibernateException {
    Session s = (Session) session.get();
    // Open a new Session, if this Thread has none yet
    if (s == null) {
        s = sessionFactory.openSession();
        session.set(s);
    }
    return s;
}

public static void closeSession() throws HibernateException {
    Session s = (Session) session.get();
    session.set(null);
    if (s != null)
        s.close();
}
}


public class javism_jaxb_xml_to_object {
public static void main(String[] args) throws JAXBException
{
    Session session = HibernateUtil.currentSession();
  Transaction tx = null;
    tx = session.beginTransaction();
            javism_jaxb cust = new javism_jaxb();
            cust.setName("Vasay");
            cust.setId(1);
            cust.setAge(34);
            session.save(cust);
            tx.commit();
}
}

But get exeption

  Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:111)
at test.HibernateUtil.<clinit>(HibernateUtil.java:16)
at test.javism_jaxb_xml_to_object.main(javism_jaxb_xml_to_object.java:25)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 3 more

What im doing wrong?

UPDATE

After adding commons-logging-1.1.1.jar in classpath. And refreshing hibernate3.jar from 3.0.3 to 3.5 i get another exeption

Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/DocumentException
at test.HibernateUtil.<clinit>(HibernateUtil.java:16)
at test.javism_jaxb_xml_to_object.main(javism_jaxb_xml_to_object.java:25)
Caused by: java.lang.ClassNotFoundException: org.dom4j.DocumentException
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 2 more

but if i use hibernate3.jar version 3.0.3 i get this

15.08.2012 11:01:30 org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.0.3
15.08.2012 11:01:30 org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
15.08.2012 11:01:30 org.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
15.08.2012 11:01:30 org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
15.08.2012 11:01:30 org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
15.08.2012 11:01:30 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
  • 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-09T23:30:51+00:00Added an answer on June 9, 2026 at 11:30 pm

    You need to add apache commons logging jar in your classpath if you have it. Otherwise download it from apache and add it in your project and add it in project’s classpth.

    UPDATE

    download dom4j library here and add it in classpath.

    UPDATE2

    INFO: Hibernate 3.0.3 –> INFO LOG SHOWING hibernate version you are using.

    INFO: hibernate.properties not found –> INFO LOG SHOWING hibernate.properties not found. This is an alternate way to give hibernate properties, you do provide these properties in hibernate.cfg.xml.

    For more info check here

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

Sidebar

Related Questions

My ServletContextListener: @WebListener public class RunServlet implements ServletContextListener { private ScheduledExecutorService scheduler; @Override public
I just downloaded new release of Hibernate 4.0.1 final release. It is very strange
I'm new on object persistence with Hibernate. I'm reading a book to try to
I am trying to write a unit test for the following class: @Transactional public
Currently when I try to insert new records I am getting an error: [ERROR]
I am new to Spring and Hibernate. I tried to create a simple application
When I try to save a new entity to the database, I have the
I have this simple situation: @Entity public class Customer{ @ManyToMany(fetch=FetchType.EAGER) @Cascade(CascadeType.SAVE_UPDATE) private List<Product> products=new
My first question here and i'll try to be specific. I am quite new
I am new to hibernate and I'm trying to create a sample hibernate search

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.