-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: hibernate configuration problem
PostPosted: Mon May 12, 2008 3:36 pm 
Newbie

Joined: Mon May 12, 2008 3:31 pm
Posts: 4
Hi all,

I am completely new to hibernate and was trying out my first hibernate program.

SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();

This is throwing null pointer exception... I have hibernate.cfg.xml file in the build path( inside /src folder outside any package). I even see the file in the build path after compilation. But when i try to run its throwing exception. So how do i handle this? am i doing something wrong? any suggestion/help is most welcome. Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 12, 2008 11:36 pm 
Senior
Senior

Joined: Wed Sep 19, 2007 9:31 pm
Posts: 191
Location: Khuntien (Indonesia)
can you post the stack trace please?


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 13, 2008 9:08 am 
Newbie

Joined: Mon May 12, 2008 3:31 pm
Posts: 4
SIau_Tie wrote:
can you post the stack trace please?


thank for responding but i got it working. but am having one more problem, hibernate.cfg.xml is being called but its not able to find the mapping file specified xxx.hbm.xml I have placed this xxx.hbm.xml in src folder next to all .java files. am I doing anything wrong?

Following is what i get ...

org.hibernate.MappingException: Resource: contact.hbm.xml not found
at org.hibernate.cfg.Configuration.addResource(Configuration.java:442)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1381)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1353)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1335)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1302)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1264)
at mypackage.InsertServlet.main(InsertServlet.java:15)
Exception in thread "main" java.lang.NullPointerException
at mypackage.InsertServlet.main(InsertServlet.java:37)

Thanks foe nay suggestions/idea...


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 13, 2008 9:34 am 
Newbie

Joined: Wed Apr 30, 2008 1:49 pm
Posts: 7
Try specifying the full path of the mapping file in the configuration file.
e.g.:

Code:
<mapping resource="com/tsg/common/model/Site.hbm.xml" />


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 13, 2008 9:48 am 
Newbie

Joined: Mon May 12, 2008 3:31 pm
Posts: 4
BenDave wrote:
Try specifying the full path of the mapping file in the configuration file.
e.g.:

Code:
<mapping resource="com/tsg/common/model/Site.hbm.xml" />



I even tried specifying full path name in the tag.. But it still didnot work
C:/HibernateExample/src/java/mypackage/contact.hbm.xml


Top
 Profile  
 
 Post subject: Re: hibernate configuration problem
PostPosted: Sat Aug 02, 2008 8:44 am 
Newbie

Joined: Sat Aug 02, 2008 8:33 am
Posts: 1
Can you please let me know how did you solve this problem.. i face the similar problem..

labi_laba wrote:
Hi all,

I am completely new to hibernate and was trying out my first hibernate program.

SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();

This is throwing null pointer exception... I have hibernate.cfg.xml file in the build path( inside /src folder outside any package). I even see the file in the build path after compilation. But when i try to run its throwing exception. So how do i handle this? am i doing something wrong? any suggestion/help is most welcome. Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.