-->
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.  [ 3 posts ] 
Author Message
 Post subject: Reading Hibernate Config File As Input Stream
PostPosted: Sun May 16, 2004 4:29 am 
Beginner
Beginner

Joined: Sun Dec 21, 2003 9:18 pm
Posts: 21
Hi,

I am trying to read my hibernate.cfg.xml as an input stream
Code:
sessionFactory = new Configuration()
            .addInputStream(getMapping())
            .buildSessionFactory();


this is how I do the getMapping():

Code:
public InputStream getMapping()
{
      return this.getClass().getResourceAsStream("/cfg/hibernate.cfg.xml");
}


But this will throw:

[tcp-connection-1][common.OPDGLogger][debug],2004-05-16 15:51:01,918 - INIT SESSION FACTORY80156 [tc
p-connection-1] DEBUG Forum.component.TopicBean - INIT SESSION FACTORY
[tcp-connection-1][net.sf.hibernate.cfg.Configuration][addInputStream],2004-05-16 15:51:01,988 - Could not configure datastore from input streamorg.dom4j.DocumentException: null Nested exception: null

at org.dom4j.io.SAXReader.read(SAXReader.java:358)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:281)
at common.HibernateDBUtil.initFactory(HibernateDBUtil.java:100)
at common.HibernateDBUtil.getSession(HibernateDBUtil.java:52) ...

Any help is greatly appreaciated.

Thanks,
inoel


[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 16, 2004 5:55 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Use a debugger. I am pretty sure getResourceAsStream() returns null in your case.


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 16, 2004 10:21 am 
Beginner
Beginner

Joined: Sun Dec 21, 2003 9:18 pm
Posts: 21
Well actually the InputStream itself is not null. when I use InputStream.available() it return an integer > 0. So I assume the InputStream return something.

But I have not checked what inside the stream actually.....


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