• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

regarding hibernate

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am using hibernate in netbaens
I am getting exception like this

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
org.hibernate.MappingNotFoundException: file: hib\classes\personVshare.hbm.xml not found
at org.hibernate.cfg.Configuration.addFile(Configuration.java:307)
at org.hibernate.cfg.Configuration.addFile(Configuration.java:293)
this is my client class
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

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



/**
*
* @author SS49938
*/
public class Client {
public static void main(String arg[])
{
Client c=new Client();
try
{
c.insertperson();
}
catch(Exception e)
{
e.printStackTrace();
}
}
public void insertperson()
{
Configuration Config = new Configuration();
Config=Config.configure("hibernate.cfg.xml");
Config=Config.addFile("hib/classes/personVshare.hbm.xml");
SessionFactory sessionFactory = Config.buildSessionFactory();
Session s = sessionFactory.openSession();

Person p=new Person("s","r");
Transaction tx=s.beginTransaction();
s.save(p);
tx.commit();
s.close();


}
}
where to place all xml files
can any one help me
thanks in advance.
 
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hib\classes\personVshare.hbm.xml not found means that that file is not anywhere on youre path but is defined in youre cfg.xml file.

to fix this error make sure that java can see this file when you run youre application...

how do you test this ? just temporarily replace the main method in youre app this (output true means hibernate should see it to) .

public static void main(String[] args)
{

System.out.println(new File("hib\classes\personVshare.hbm.xml").exists())

}
 
sruthi das
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I gave like this
System.out.println(new File("build/classes/personVshare.hbm.xml").exists());
I am getting true.
but still same error.
please help me
 
sruthi das
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I gave like this
System.out.println(new File("build/classes/personVshare.hbm.xml").exists());
I am getting true.
but still same error.
please help me
 
reply
    Bookmark Topic Watch Topic
  • New Topic