• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

session null

 
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this is my Contact.java


this is contact.hbm.xml


this is config.xml


this is main class



this is the output



that means session doesn't create.
Where is the Error?

I have already added hibernate3.jar,mysql-connector-java-3.0.16-ga-bin.jar and commons-logging-1.0.4.jar to Build path
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Turn up logging to debug level so you can see what's wrong.
 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I place a Debug pointer at this line
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session =sessionFactory.openSession();

and then press F6.
this is i got.
I can't understand what happen?



 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Still I am unable to fine where is the Error?
 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I am using Eclips ,So i think it is not need to add mysql connector to CLASSPATH ?
I already added mysql-connector.jar as a library.
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i think that it might not finding the hibernate.cfg the you have it on your root source package??... can you handle over a eclipse proyect so i can see if i get the same error??
 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is my folder stucture
http://asliyanage.blogspot.com/2010/01/blog-post.html
 
Jose Ayerdis
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try forcing the path file with an absolute path let see what happens something like this

 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here is my file path


when i attempt to use this it says invalid escap sequence



Here is a Scrennshot
http://asliyanage.blogspot.com/2010/01/blog-post_24.html
 
Jose Ayerdis
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try using the double backslash

D:\\PROJECT\\Gwt-eclips\\hibernateexample\\src\\roseindia\\tutorial\\hibernate\\hibernate.cfg.xml
 
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jose Ayerdis wrote:try using the double backslash

D:\\PROJECT\\Gwt-eclips\\hibernateexample\\src\\roseindia\\tutorial\\hibernate\\hibernate.cfg.xml


Or forward slashes. I always use forward slashes for file separators in Java source, regardless of the platform on which the application should run.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or File.pathSeparator.
 
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Put hibernate.cfg.xml into your src-folder and Hibernate will find it.
 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I change my class now


here still problem



 
Christian Dillinger
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's useless to get a File-Object if you don't use ist... Take a look into the Hibernate api-doc, where to put the path to the config-file. And again: just put it into the src-Folder and it works. Hibernate looks for a file named hibernate.cfg.xml there. You only have to configure the path if you don't put into the "root"-folder.
 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using eclips.How to set path in eclips
 
Christian Dillinger
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you read the answers posted here?!?

If you put hibernate.cfg.xml into the src-folder and not into any package, Hibernate will find it. If you want to put into a special package take a look into the API and find out that that you have to use new Configuration().configure(SET THE RIGHT FILE *HERE*)....
 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok
I put it.
now path of config file is
D:\PROJECT\Gwt-eclips\hibernateexample\src\hibernate.cfg.xml

here is a Screenshot
http://asliyanage.blogspot.com/2010/01/blog-post_25.html



Still i got this error

 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What happens on line 37 of the class FirstExample?
 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
session.flush();
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So you have no session, in which case you will have a stack trace explaining why (assuming you are running the code you have posted above).
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic