-->
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.  [ 7 posts ] 
Author Message
 Post subject: Cannot locate hibernate.cfg.xml and log4j.properties
PostPosted: Sun Feb 20, 2005 12:24 am 
Beginner
Beginner

Joined: Sun Feb 20, 2005 12:14 am
Posts: 49
I am new to hibernate and am using eclipse.

I have a project with the following structure

src
---hibernate.cfg.xml
---log4j.properties
---com
------allegro
---------event
------------Event.java
------------EventManager.java
------------Event.hbm.xml
lib
data
bin

I point to EventManager.java and then use the Run as application from the eclipse menu. This generates the following error. How do I specify the location for hibernate.cfg.xml and log4j.properties to be used???

Thank you.

Initializing Hibernate
log4j:WARN No appenders could be found for logger (net.sf.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
net.sf.hibernate.HibernateException: /hibernate.cfg.xml not found
at net.sf.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:886)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:910)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:897)
at src.com.allegro.events.EventManager.<init>(EventManager.java:22)
at src.com.allegro.events.EventManager.main(EventManager.java:32)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 20, 2005 8:01 pm 
Beginner
Beginner

Joined: Sun Feb 20, 2005 12:14 am
Posts: 49
Here is the code for EventManager.java if its helpful to see whats wrong
:

package src.com.allegro.events;

import net.sf.hibernate.HibernateException;
import net.sf.hibernate.SessionFactory;
import net.sf.hibernate.cfg.Configuration;

public class EventManager
{
private SessionFactory sessionFactory = null;

public EventManager()
{
try
{
System.out.println("Initializing Hibernate");
sessionFactory = new Configuration().configure().buildSessionFactory();
System.out.println("Finished Initializing Hibernate");
}
catch(HibernateException ex)
{
ex.printStackTrace();
}
}
public static void main (String args[])
{
EventManager instance = new EventManager();
System.exit(0);
}

}


Top
 Profile  
 
 Post subject: classpath
PostPosted: Wed Feb 23, 2005 6:10 pm 
Newbie

Joined: Wed Feb 23, 2005 3:34 pm
Posts: 16
Location: Irving, Tx
Place the cfg and log4j files in a /WEB_INF/classes directory,
(or)
otherwise ensure that the directory (src) is in the classpath.


Top
 Profile  
 
 Post subject: Resolved
PostPosted: Wed Feb 23, 2005 6:27 pm 
Beginner
Beginner

Joined: Sun Feb 20, 2005 12:14 am
Posts: 49
1. The app i am running is a standalone java application that uses Hibernate.

2. I resolved the issue by correcting a few package nuances.

Thanks.


Top
 Profile  
 
 Post subject: package nuances
PostPosted: Wed Jun 15, 2005 11:12 pm 
Newbie

Joined: Wed Jun 15, 2005 11:08 pm
Posts: 1
Quote:
2. I resolved the issue by correcting a few package nuances.

I was wondering if you can give some more detail about what you did. I'm experiencing the same problem.

Thanks,
Sayed


Top
 Profile  
 
 Post subject: Re: package nuances
PostPosted: Thu Jun 16, 2005 3:24 am 
Newbie

Joined: Sat Jun 11, 2005 5:27 am
Posts: 11
hass0002 wrote:
Quote:
2. I resolved the issue by correcting a few package nuances.

I was wondering if you can give some more detail about what you did. I'm experiencing the same problem.

Thanks,
Sayed


I had some hastle with this. I wound up loading the configuration explicly in the code.

Code:
        org.hibernate.cfg.Configuration cfg = new org.hibernate.cfg.Configuration();
        cfg.configure("hibernate.cfg.xml");
        factory = cfg.buildSessionFactory();


The string is a resource path, as used by ClassLoader.getResource() i.e. relative to the class path directories.

This shouldn't be necessary, as I understand it, but I still need it under Hibernate 3.

[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2005 3:29 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
for some reason log4j.properties and hibernate.cfg.xml is not copied to the build directory where you run your classes from with eclipse.

that happens automatically for me.

ask in the eclipse newsgroups if it keeps bugging.

-max

_________________
Max
Don't forget to rate


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