facebook

error in hibernate : executed in myeclipse

  1. MyEclipse Archived
  2.  > 
  3. Documentation
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #310115 Reply

    error is : log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
    log4j:WARN Please initialize the log4j system properly.
    /hibernate.cfg.xml not found
    Exception in thread “main” java.lang.NullPointerException
    at dto.working.main(working.java:28)

    code:

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

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

    SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
    session =sessionFactory.openSession();
    Addresses obj1 = new Addresses();
    obj1.setAddressid(1);
    obj1.setChangedate(null);
    obj1.setChangeuserid(null);
    obj1.setCity(“delhi”);
    obj1.setHouseno(“187”);
    obj1.setStreet(“rohini”);
    obj1.setZip(“110085”);
    obj1.setCountries(“India”);
    obj1.setCreationdate(null);
    session.save(obj1);
    } catch(Exception e){
    System.out.println(e.getMessage());
    }finally{

    session.flush();
    session.close();

    }
    }
    }

    #310127 Reply

    vaibhavkhanna,
    As your error indicates, please verify the location of your “hibernate.cfg.xml”. It should be placed directly under the src folder of your project. Please refer to the following link for further reference –
    https://forum.hibernate.org/viewtopic.php?t=936025&sid=cad9f78775ac43e2ee4269979a7ed8f9

    Let me know if that helps.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: error in hibernate : executed in myeclipse

You must be logged in to post in the forum log in