-->
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.  [ 4 posts ] 
Author Message
 Post subject: Web Project and Hibernate Exception.
PostPosted: Tue Apr 05, 2011 7:35 am 
Newbie

Joined: Thu Mar 31, 2011 2:42 am
Posts: 4
I am running a web application that uses Hibernate for data persistence.

Now I have created another webproject and included necessary jar files etc. While fetching data I got an exception.
Code:
Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.sit.util.HibernateUtil.<clinit>(Unknown Source)
    at java.lang.J9VMInternals.initializeImpl(Native Method)
    at java.lang.J9VMInternals.initialize(J9VMInternals.java:177)
    at com.core.dao.OpenIncidentDao.getAllOpenIncidents(Unknown Source)
    at Test.main(Test.java:17)
Caused by: org.hibernate.HibernateException: /hibernate.cfg.xml not found
    at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:147)
    at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1405)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:1427)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:1414)
    ... 5 more


My other web project is running fine. Also hibernate.cfg.xml is in its place. hibernate.cfg.xml is under EarContent/hibernate.cfg.xml. Both the web projects and hibernate project are added in EAR.


Last edited by imrantariq on Wed Jun 13, 2012 3:34 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Web Project and Hibernate Exception.
PostPosted: Wed Apr 06, 2011 2:35 am 
Beginner
Beginner

Joined: Mon Apr 04, 2011 3:31 am
Posts: 41
Hi,
I think your Programme is not able to locate your
mapping resource

_________________
Thanks
Niki


Top
 Profile  
 
 Post subject: Re: Web Project and Hibernate Exception.
PostPosted: Wed Apr 06, 2011 8:27 am 
Newbie

Joined: Thu Jul 10, 2008 6:45 am
Posts: 2
Location: Bangalore
Can you please post how you are building the SessionFactory, based on that we can analyze and findout the issue.

_________________
Thanks & Regards,
Rajagopal Yendluri(Raj)


Top
 Profile  
 
 Post subject: Re: Web Project and Hibernate Exception.
PostPosted: Wed Apr 06, 2011 8:29 am 
Beginner
Beginner

Joined: Mon Apr 04, 2011 3:31 am
Posts: 41
import org.hibernate.HibernateException;

import org.hibernate.Session;

import org.hibernate.SessionFactory;

import org.hibernate.cfg.Configuration;



public class HibernateUtil

{

private static org.hibernate.SessionFactory sessionFactory;



public static SessionFactory getSessionFactory()

{

if (sessionFactory == null)

{

initSessionFactory();

}

return sessionFactory;

}



private static synchronized void initSessionFactory()

{

try

{

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

}

catch(HibernateException e)

{

e.printStackTrace();

}

}



public static Session getSession()

{

return getSessionFactory().getCurrentSession();

}

}

_________________
Thanks
Niki


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.