-->
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.  [ 9 posts ] 
Author Message
 Post subject: problem with hibernate.cfg.xml
PostPosted: Wed May 26, 2004 11:00 am 
Newbie

Joined: Wed May 26, 2004 10:43 am
Posts: 4
Hello,

I have a problem with Hibernate:
during the execution of my file .class, I have this error : "/hibernate.cfg.xml not found" but the file is in the classpath.
I tested by modifying the line "new Configuration()" but there is always the same error.

my version of hibernate : 2.1.3
my version of java : 1.4.2

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 26, 2004 11:53 am 
Senior
Senior

Joined: Fri Nov 21, 2003 5:55 am
Posts: 155
Are you sure when you add config.xml to the Configuration that the path is good?


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 27, 2004 3:13 am 
Newbie

Joined: Wed May 26, 2004 10:43 am
Posts: 4
Yes. I have checked several times and the path is good.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 27, 2004 5:47 am 
Regular
Regular

Joined: Wed May 12, 2004 3:03 am
Posts: 51
Location: France
Hi,

What IDE are you using?

Could you show the tree of your files...

Charles


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 27, 2004 6:55 am 
Newbie

Joined: Wed May 26, 2004 10:43 am
Posts: 4
I don't use IDE but I have tested with NetBeans and I have the same error.

in my file "connection":

try {
SessionFactory sessionsPg = new Configuration().configure("/hibernate.cfg.xml.pg").buildSessionFactory();
SessionFactory sessions = new Configuration().configure("/hibernate.cfg.xml.ms").buildSessionFactory();
session = sessions.openSession();
sessionPg = sessionsPg.openSession();
}
catch (HibernateException e) {
e.printStackTrace();
}


and the files hibernates.cfg.xml.* are in the root of the repository of work.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 27, 2004 9:14 am 
Senior
Senior

Joined: Fri Nov 21, 2003 5:55 am
Posts: 155
I'm not sure that you can use this name...("/hibernate.cfg.xml.pg").
Maybe problem come from it


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 27, 2004 9:25 am 
Newbie

Joined: Wed Jan 07, 2004 8:48 am
Posts: 11
Hi, I'm a colleague of Gael. I have developed the code he's trying to get running on his PC. It's running fine on mine.....

I remember I have had a problem at one time with the path to specify config files, and I set to leading slash and put the config files in a directory specified in the classpath.

I mimicked my environment on his PC, and I still get the same error.
I set all jars in the classpath. Here is the file where I set my environment variables:
Code:
CLASSPATH=/home/rb/migrationcheck
HIBERNATE_HOME=/opt/hibernate
JUNIT_HOME=/opt/junit/junit3.8.1/


for f in $HIBERNATE_HOME/lib/*jar; do CLASSPATH=$CLASSPATH:$f; done
for file in $HIBERNATE_HOME/tools/lib/*jar; do CLASSPATH=$CLASSPATH:$file; done
for file in $HIBERNATE_HOME/tools/*jar; do CLASSPATH=$CLASSPATH:$file; done
CLASSPATH=$CLASSPATH:$HIBERNATE_HOME/hibernate2.jar
CLASSPATH=$CLASSPATH:$JUNIT_HOME/junit.jar


export HIBERNATE_HOME CLASSPATH


here's the classpath I get:
Code:
CLASSPATH=/home/rb/migrationcheck:/opt/hibernate/lib/ant-1.5.3.jar:/opt/hibernate/lib/ant-optional-1.5.3.jar:/opt/hibernate/lib/c3p0-0.8.4.5.jar:/opt/hibernate/lib/cglib-full-2.0.1.jar:/opt/hibernate/lib/commons-collections-2.1.jar:/opt/hibernate/lib/commons-dbcp-1.1.jar:/opt/hibernate/lib/commons-lang-1.0.1.jar:/opt/hibernate/lib/commons-logging-1.0.3.jar:/opt/hibernate/lib/commons-pool-1.1.jar:/opt/hibernate/lib/concurrent-1.3.2.jar:/opt/hibernate/lib/connector.jar:/opt/hibernate/lib/dom4j-1.4.jar:/opt/hibernate/lib/ehcache-0.7.jar:/opt/hibernate/lib/jaas.jar:/opt/hibernate/lib/jboss-cache.jar:/opt/hibernate/lib/jboss-common.jar:/opt/hibernate/lib/jboss-jmx.jar:/opt/hibernate/lib/jboss-system.jar:/opt/hibernate/lib/jcs-1.0-dev.jar:/opt/hibernate/lib/jdbc2_0-stdext.jar:/opt/hibernate/lib/jgroups-2.2.1.jar:/opt/hibernate/lib/jta.jar:/opt/hibernate/lib/junit-3.8.1.jar:/opt/hibernate/lib/odmg-3.0.jar:/opt/hibernate/lib/oscache-2.0.jar:/opt/hibernate/lib/proxool-0.8.3.jar:/opt/hibernate/lib/swarmcache-1.0rc2.jar:/opt/hibernate/lib/xalan-2.4.0.jar:/opt/hibernate/lib/xerces-2.4.0.jar:/opt/hibernate/lib/xml-apis.jar:/opt/hibernate/tools/lib/jdom.jar:/opt/hibernate/tools/hibernate-tools.jar:/opt/hibernate/hibernate2.jar:/opt/junit/junit3.8.1//junit.jar

Just see that /home/rb/migrationcheck, the directory where the config file is located, is in the claspath....

Code:
~/migrationcheck$ ls
custdb                            CustomerOrdersQuantity.java  HibernateConnections.java
CustomerBillingAddressTest.class  CustomersTest.class          hibernate.properties.ms
CustomerBillingAddressTest.java   CustomersTest.java           hibernate.properties.pg
CustomerCompanyName.class         CustomerVat.class            mscustdb
CustomerCompanyName.java          CustomerVat.java             TestDatabaseMigration.class
CustomerContactNameTest.java      CVS                          TestDatabaseMigration.java
CustomerDescription.class         hibernate.cfg.xml.ms         TestTemplate.java
CustomerDescription.java          hibernate.cfg.xml.pg
CustomerOrdersQuantity.class      HibernateConnections.class


and when I run:
Code:
~/migrationcheck$ java TestDatabaseMigration
net.sf.hibernate.HibernateException: hibernate.cfg.xml.pg not found
        at net.sf.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:849)
        at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:873)
        at HibernateConnections.<clinit>(HibernateConnections.java:22)
        at CustomersTest.suite(CustomersTest.java:40)
        at TestDatabaseMigration.suite(TestDatabaseMigration.java:8)
        at TestDatabaseMigration.main(TestDatabaseMigration.java:19)
Testing customers with id between 0and 100
Exception in thread "main" java.lang.NullPointerException
        at CustomersTest.suite(CustomersTest.java:47)
        at TestDatabaseMigration.suite(TestDatabaseMigration.java:8)
        at TestDatabaseMigration.main(TestDatabaseMigration.java:19)



The solution is certainly too obvious for us to see it from here....

Thanks for the help.

Raph


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 27, 2004 10:55 am 
Senior
Senior

Joined: Fri Nov 21, 2003 5:55 am
Posts: 155
Your problem is very strange but if it's work on your computer, problem comes from a path or a jar or something like that.
Just a little error...
Good luck to find it :)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 01, 2004 6:10 am 
Newbie

Joined: Wed May 26, 2004 10:43 am
Posts: 4
Hibernate works perfectly !

I have erased all the references of java and hibernate and re-installed the system properly. After this, all is ok and works.
I think that the problem came from a path or a jar.

Thanks


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