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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:44:22+00:00 2026-05-27T14:44:22+00:00

I have programmed a simple hibernate app which leaves me with errors. The following

  • 0

I have programmed a simple hibernate app which leaves me with errors. The following is my code.

Contact.java

public class Contact {
 private String firstName;
 private String lastName;
 private String email;
 private long id;


 public String getEmail() {
  return email;
 }


 public String getFirstName() {
  return firstName;
 }


 public String getLastName() {
  return lastName;
 }


 public void setEmail(String string) {
  email = string;
 }


 public void setFirstName(String string) {
  firstName = string;
 }


 public void setLastName(String string) {
  lastName = string;
 }


 public long getId() {
  return id;
 }


 public void setId(long l) {
  id = l;
 }

}

FirstExample.java

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



public class FirstExample {
 public static void main(String[] args) {
  Session session = null;

  try{

  SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
  session =sessionFactory.openSession();

  System.out.println("Inserting Record");
  Contact contact = new Contact();
  contact.setId(3);
  contact.setFirstName("Tausif");
  contact.setLastName("rahmathullah");
  contact.setEmail("t.r@vl.net");
  session.save(contact);
  System.out.println("updated");
  }catch(Exception e){
    System.out.println(e.getMessage());
    e.printStackTrace();
   }finally{
    if(session!=null){
     session.flush();
     session.close();
    }
   }
  }
 }

hibernate.cfg.xml

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
 <session-factory>
  <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
  <property name="hibernate.connection.url">jdbc:mysql://localhost/simpHiber</property>
  <property name="hibernate.connection.username">root</property>
  <property name="hibernate.connection.password">root</property>
  <property name="hibernate.connection.pool_size">10</property>
  <property name="show_sql">true</property>
  <property name="dialect">org.hibernate.dialect.MySQL5Dialect</property>
  <property name="hibernate.hbm2ddl.auto">update</property>
  <mapping resource="contact.hbm.xml"/>
 </session-factory>
</hibernate-configuration>

contact.hbm.xml

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC 
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
 <class name="Contact" table="CONTACT">
  <id name="id" type="long" column="ID" >
   <generator class="assigned"/>
  </id>

  <property name="firstName">
   <column name="FIRSTNAME" />
  </property>
  <property name="lastName">
   <column name="LASTNAME"/>
  </property>
  <property name="email">
   <column name="EMAIL"/>
  </property>
 </class>
</hibernate-mapping>

Error

D:\TausifProjects\simpHiber>java FirstExample
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Level
    at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60)
    at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:197)
    at FirstExample.main(FirstExample.java:15)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Level
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 3 more

Jar files in the buildpath

antlr-2.7.6.jar
commons-collections-3.1.jar
dom4j-1.6.1.jar
hibernate3.jar
hibernate3.3.1-slf4j-api-1.5.2.jar
hibernate-jpa-2.0-api-1.0.1.Final.jar
javassist-3.4.ga.jar
jcl-over-slf4j-1.5.2.jar
jta-1.1.jar
mysql-connector-java-5.0.0-bin.jar
slf4j-log4j12-1.5.5.jar
slf4j-jdk14-1.5.2-sources.jar

Please help me. Thanks in advance.

  • 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-27T14:44:23+00:00Added an answer on May 27, 2026 at 2:44 pm

    If you include slf4j-log4j.jar, then you must also include the log4j jar. Slf4j is a logging facade, which means it gives you a uniform interface to multiple other logging APIs.

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

Sidebar

Related Questions

I have programmed a simple hibernate app which isn't updating the table. The following
I have programmed a simple app that every X minutes checks if an image
Once I have programmed GUI with Java and have used Form Layouts. Form layout
I have a webservice programmed in coldfusion which I'm attempting to consume using c#.net.
I have programmed in Java some and tried to use net-beans to create a
I have a rather simple web-service which exposes data from sql server. It will
I've just finished reading 'Java for Dummies' and have begun to create a simple
I have programmed a very simple script with jQuery. The idea is to fade
I have not programmed in c++ in a long time and want some simple
I have some pyunit unit tests for a simple command line programme I'm writing.

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.