-->
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: WARNUNG: hibernate.cfg.xml not found
PostPosted: Fri Nov 11, 2005 6:33 am 
Newbie

Joined: Fri Nov 11, 2005 6:08 am
Posts: 1
hallo zusammen

Ich versuche gerade die Konfiguration aus der hibernate.cfg.xml zu lesen.
Bekomme leider folgende Meldung:
-----
11.11.2005 11:02:07 net.sf.hibernate.cfg.Environment <clinit>
INFO: Hibernate 2.1.8
11.11.2005 11:02:07 net.sf.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
11.11.2005 11:02:07 net.sf.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
11.11.2005 11:02:07 net.sf.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
11.11.2005 11:02:07 net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: kkm/Honey.hbm.xml
11.11.2005 11:02:08 net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: kkm.Honey -> honey
11.11.2005 11:02:13 net.sf.hibernate.cfg.Configuration configure
INFO: configuring from resource: kkm/hibernate.cfg.xml
11.11.2005 11:02:13 net.sf.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: kkm/hibernate.cfg.xml
11.11.2005 11:02:13 net.sf.hibernate.cfg.Configuration getConfigurationInputStream
WARNUNG: kkm/hibernate.cfg.xml not found
----
gebe ich die informationen direkt im code an funktionit alles so wie gewollt, er gibt mir die tabelle in der console aus.
---
Configuration config = new Configuration().addResource("kkm/Honey.hbm.xml");
config = new Configuration().addClass(Honey.class)

.setProperty("hibernate.dialect",
"net.sf.hibernate.dialect.MySQLDialect")
.setProperty("hibernate.connection.driver_class",
"com.mysql.jdbc.Driver")
.setProperty("hibernate.connection.url",
"jdbc:mysql://localhost/firsthibernate")
.setProperty("hibernate.connection.username",
"test")
.setProperty("hibernate.connection.password",

SessionFactory sf = config.buildSessionFactory();
Session session = sf.openSession();
String SQL_STRING = "select from Honey";
Query query = session.createQuery(SQL_STRING);
----
wolle dann mit den code die xml datei angeben:

try {
Configuration config = new Configuration().addResource("kkm/Honey.hbm.xml");

config = new Configuration().addClass(Honey.class)
.configure("kkm/hibernate.cfg.xml");


SessionFactory sf = config.buildSessionFactory();
Session session = sf.openSession();
String SQL_STRING = "select from Honey";
Query query = session.createQuery(SQL_STRING);
----
Doch leider bekomme wie oben erwähnt die Meldung das er die Datei nicht finden kann. Ich habe sie schon in jeden Ordern im Projekt hineinkopiert, aber vergebens!

vielleicht hat ja jemand eine idee
mfg
jelly


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 7:35 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
Die cfg.xml Datei muss im Root des Classpathes sein. Alternativ kann mit
Code:
public Configuration configure(String resource)

auch ein andrer Ort spezifiziert werden.

HTH
Ernst


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 03, 2006 3:35 am 
Newbie

Joined: Fri Feb 03, 2006 3:24 am
Posts: 3
Ich habe nun das selbe Problem.

Ich habe folgende Zeilen:

Code:
configFileURL = HibernatePlugIn.class.getResource(_configFilePath);

            tempString = ""+configFileURL;
            System.out.println(" tempString: "+tempString);
            tempString = tempString.substring(6);
            System.out.println(" tempString: "+tempString);
            context = _servlet.getServletContext();

            if (_log.isDebugEnabled()) {
                _log.debug("Initializing Hibernate from "
                        + _configFilePath + "...");
            }

            configuration = (new Configuration()).configure(tempString);
            _factory = configuration.buildSessionFactory();


Ich hole mir mit getResource den Pfad der hibernate.cfg.xml, welcher auch richtig erkannt wird, nämlich:

Quote:
configFilePath: /hibernate.cfg.xml
tempString: file:/D:/JBuilder2006/Projects/MCM/WebModule1/WEB-INF/classes/hibernate.cfg.xml
tempString: D:/JBuilder2006/Projects/MCM/WebModule1/WEB-INF/classes/hibernate.cfg.xml


Allerdings kommt beim starten des Webmodules folgende Fehlermeldung:

Quote:
08:31:37,317 INFO Configuration:1286 - configuring from resource: D:/JBuilder2006/Projects/MCM/WebModule1/WEB-INF/classes/hibernate.cfg.xml
08:31:37,317 INFO Configuration:1263 - Configuration resource: D:/JBuilder2006/Projects/MCM/WebModule1/WEB-INF/classes/hibernate.cfg.xml
08:31:37,347 ERROR HibernatePlugIn:132 - Exception while initializing Hibernate.
08:31:37,387 ERROR HibernatePlugIn:133 - Rethrowing exception...
org.hibernate.HibernateException: D:/JBuilder2006/Projects/MCM/WebModule1/WEB-INF/classes/hibernate.cfg.xml not found



Ich habe die hibernate.cfg.xml in den Ordner /WEB-INF/classes/ gegeben, auch in /WEB-INF/ und sogar direkt ins /WebModule1/, trotzdem sagt er jedesmal das er die Datei nicht findet. Ich bin mir ziemlich sicher das im Config-File kein Fehler ist, warum findet er die Datei dann nicht?


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.