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