• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Null Pointer Exception @ SessionFactory

 
Talha Kabakus
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello to everyone,

I'm new to Hibernate. I just want to do a sample project with Hibernate. But I've been taking exceptions, I'll be happy if someone can help me..
Thanks in advance..

And here's my hibernate.cfg.xml file:

Full stacktrace:
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34237
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Talha,
The exception says it is being thrown in line 30 in saveOrUpdate. Which line is line 30? If I had to guess, I would imagine it is one of the lines in the catch or finally block. You should have a null check so you aren't trying to rollback the transaction if it is null. In other words, if Hibernate fails on creating a session, the code throws a Null Pointer in the catch block and you don't know what the original exception is. The finally block should have a similar null check for session.
 
Talha Kabakus
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply Jeanne..

Now I'm taking another exception :

org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping clazz="model.Users"/>

Here's my Users class that is generated Hibernate tools..

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic