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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:10:10+00:00 2026-06-01T03:10:10+00:00

I know this has been asked a dozen times. I must be brain dead

  • 0

I know this has been asked a dozen times. I must be brain dead today as I’ve tried modifying my xml file a hundred ways and I can’t figure it out.

Error stack when I run the driver:

16 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.3.2.GA
31 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found
31 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
31 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
78 [main] INFO org.hibernate.cfg.Configuration - configuring from resource: test_hibernate/hibernate.cfg.xml
78 [main] INFO org.hibernate.cfg.Configuration - Configuration resource: test_hibernate/hibernate.cfg.xml
125 [main] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : test_hibernate/contact.hbm.xml
Exception in thread "main" Could not parse mapping document from resource            test_hibernate/contact.hbm.xml
java.lang.NullPointerException
at test_hibernate.MyExample.main(MyExample.java:29)

Here’s the MySQL code for how I built the table:

create database HibernateTest;
drop table contact;
Create table CONTACT(
ID int(15),
FIRSTNAME varchar(50) ,
LASTNAME varchar(50),
EMAIL varchar(150)); 
describe contact;

Here’s my mapping file:

<?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="test_hibernate.Contact" table="CONTACT">
<id name="id" column="ID" >
<generator class="increment" />
</id>
<property name="firstName" column="FIRSTNAME" />
<property name="lastName" column="LASTNAME" />
<property name="email" column="EMAIL" />
</class>
</hibernate-mapping>

And here’s my config file:

<?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/hibernatetest</property>
  <property name="hibernate.connection.username">###</property>
  <property name="hibernate.connection.password">###</property>
  <property name="hibernate.connection.pool_size">10</property>
  <property name="show_sql">true</property>
  <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
  <property name="hibernate.hbm2ddl.auto">update</property>
  <!-- Mapping files -->
  <mapping resource="test_hibernate/contact.hbm.xml"/>
</session-factory>
</hibernate-configuration>

Any help is appreciated, thank you!!

Some additional information: Setup package test_hibernate and here’s my persistence file:

package test_hibernate;
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;
    }
}

and here’s my driver:

package test_hibernate;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.Transaction;

public class MyExample {

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

try{
    // This step will read hibernate.cfg.xml and prepare hibernate for use
    SessionFactory sessionFactory = new Configuration().configure("hibernate.cfg.xml").buildSessionFactory();
    session=sessionFactory.openSession();
    Transaction tx = session.beginTransaction();

    //Create new instance of Contact and set values in it by reading them from form object
    System.out.println("Inserting Record");

    Contact contact = new Contact();
    contact.setId(3);
    contact.setFirstName("Smitha");
    contact.setLastName("Rao");
    contact.setEmail("smithaxxx@yahoo.com");
    session.save(contact);
    tx.commit();
    System.out.println("Done");
}catch(Exception e){
    System.out.println(e.getMessage());
}finally{
    // Actual contact insertion will happen at this step

    session.flush();        
    session.close();
}
}
}
  • 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-01T03:10:11+00:00Added an answer on June 1, 2026 at 3:10 am

    Your mapping file looks fine . I think it may due to you use ” or “ instead of “ for the double quotations .Please try to use “ for all the double quotations.

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

Sidebar

Related Questions

I know this has been asked many times before... I have a simple ('#Div').load(file.php?id='+id+'&page='+page)
I know this has been asked several times, but I searched and I tried
I know this has been asked a dozen times here at stackoverflow, but it
I know this has probably been asked a dozen times, but I am kind
I know this has been asked different ways several times, but I'm just not
I know this has been asked thousands of times but I just can't find
I know this has been asked many times but i'm yet to find a
I know this has been asked many times before, but i still can't seem
I know this has been asked many times, but I cant find answer to
I know this has been asked several times and I have read all the

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.