public static void main(String[] args) { Singleton instance = new Singleton(); System.exit(0); }
}
as the hibernate documentation say. But when I run the Singleton to see if I can connect, I obtain the following error
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:872) at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:896) at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:883) at com.tutorial.hibernate.db.Singleton.<init>(Singleton.java:23) at com.tutorial.hibernate.db.Singleton.main(Singleton.java:31)
The hibernate.cfg.xml is in the src directory Anybody can help me!!! REgards
Hibernate looks for that file to be in the root of one of the JARs or directories on the classpath. You should be able to add a directory to the classpath in JBuilder and put the file there.
Natalia Lopez
Ranch Hand
Joined: Feb 17, 2005
Posts: 41
posted
0
Thank you for your help!! I put the hibernate.cfg.xml on the class directory and work but still not found the maping.hbm.xml files. The src directory is in the class path and I put hibernate.cfg.xml and the mapping.hbm.xml in the src directory. I wonder why they are not founded? There is some option n JBuilder that reject .xml files in the src directory? Regards
Naty
David Harkness
Ranch Hand
Joined: Aug 07, 2003
Posts: 1646
posted
0
When you moved the hibernate.cfg.xml file from your classes directory to the source directory, did it still find it? If so, then clearly Hibernate will access XML files in the source tree. If this is the case, make sure your mapping files are where Hibernate expects them.
If you're telling Hibernate about a mapped class (rather than the file itself), Hibernate will look in the same package as the file. If you specify the file directly, double-check your paths. Also, maybe post up the code you're using to perform the configuration.
If you don't get it, I'll ask one of the developers on my team that uses Eclipse how they have it set up for running JUnit tests from Eclipse which require the mapping files.
Natalia Lopez
Ranch Hand
Joined: Feb 17, 2005
Posts: 41
posted
0
Hi again When you moved the hibernate.cfg.xml file from your classes directory to the source directory, did it still find it? The answer is not I put the mapped class in the same directory than the .java class definition as the documentation say. I will go to apreciate some example in eclipse, maybe can help me !!! Or maybe JBuilder need some other configuration I really don't know. Just in case I'm using JBuilderX King Regards
Naty
David Harkness
Ranch Hand
Joined: Aug 07, 2003
Posts: 1646
posted
0
Well, none of us uses JBuilder anymore, but I'll ask if anyone remembers how to add the source directory to the class path. In the project properties, there should be a way to add any directory to the classpath, just like adding a JAR but maybe a different tab page. Is there nothing like that?
Natalia Lopez
Ranch Hand
Joined: Feb 17, 2005
Posts: 41
posted
0
Yes I put in lib directory where I have the .jar 's files but still not work. Only find it If I put in classes directory but when I rebuilt the project I lost the file I will write you If I get a solution Thank you
Look under Project Properties>Build>Resource there is a list of file types which will get copied as part of your build process. You should be able to add *.cfg.xml and *.hbm.xml (or possibly just *.xml) in there.
Yes you are. Natalia Lopez is using JBuilderX.... [ February 23, 2005: Message edited by: Paul Sturrock ]
David Harkness
Ranch Hand
Joined: Aug 07, 2003
Posts: 1646
posted
0
Oops, my bad. I sent Steven to this thread but didn't make the connection. Sorry Steven!
miguel lisboa
Ranch Hand
Joined: Feb 08, 2004
Posts: 1281
posted
0
log4j:WARN No appenders could be found for logger (net.sf.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
this means you dont have a log4j.properties file in your classpath
imagine your root folder is: MyProject inside, you'll have two folders: MyClasses and MySources Inside each one you'll have a package named MyPackage where respectively you'll keep *.class and *.java files Put hibernate.cfg.xml and log4j.properties inside: MyProject/MyClasses
and later on add the *.hbm.xml to MyProject/MyClasses/MyPackage, together with your class files hope this helps good luck
java amateur
Natalia Lopez
Ranch Hand
Joined: Feb 17, 2005
Posts: 41
posted
0
Hi everybody!!! Thanks a lot for help! I finally resolve the problem enabling .xml extension in the configuration of JBuilder. Now in the src I can see the .java and the .xml files and when rebuilt all is on classes folder. That simplicity was all the problem and solution! Till the next
Naty
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.