Since updating to most recent version of Hibernate Tools and Eclipse Fall Europa, suddenly have situation where my application runs correctly but my JUnit tests fail with a Sax parsing error. I use a variant of the HibernateUtil static section to get a configuration; in the trace below, you can see that the configuration file is found, but a validating SAX XMLReader is apparently not found. But when I run the code in my application it runs fine. This test code previously ran without problems but something has obviously changed in my setup. This has sporadically been reported in this forum (code running in application but failing in tests) and the posters have indicated that they solved their problem, but their solutions have never been posted. Sorry that this is repeat issue apparently. Have been working on this for about ten days and out of ideas at this point. Thanks in advance for any suggestions.
Hibernate version:
3.2.5
Mapping documents:
Using annotations. Here is the hibernate.cfg.xml file:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">
org.hsqldb.jdbcDriver
</property>
<property name="hibernate.connection.url">
jdbc:hsqldb:hsql://localhost
</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.dialect">
org.hibernate.dialect.HSQLDialect
</property>
<property name="current_session_context_class">thread</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">1800</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.max_statements_per_connection">50</property>
<property name="hibernate.transaction.auto_close_session">false</property>
<mapping class="edu.utah.cdmcc.entities.Patient" />
<mapping class="edu.utah.cdmcc.entities.GlucoseDecision" />
<event type="pre-update">
<listener class="org.hibernate.validator.event.ValidatePreUpdateEventListener"/>
</event>
<event type="pre-insert">
<listener class="org.hibernate.validator.event.ValidatePreInsertEventListener"/>
</event>
</session-factory>
</hibernate-configuration>
Code between sessionFactory.openSession() and session.close():Not getting that far.
Full stack trace of any exception that occurs:Code:
05:04:40,912 INFO Version:15 - Hibernate Annotations 3.2.1.GA
05:04:40,934 INFO Environment:514 - Hibernate 3.2.5
05:04:40,940 INFO Environment:547 - hibernate.properties not found
05:04:40,943 INFO Environment:681 - Bytecode provider name : cglib
05:04:40,948 INFO Environment:598 - using JDK 1.4 java.sql.Timestamp handling
05:04:41,091 DEBUG GlucosePlugin:504 - getDefault() - start
05:04:41,091 DEBUG GlucosePlugin:508 - getDefault() - end
05:04:41,092 DEBUG GlucosePlugin:504 - getDefault() - start
05:04:41,092 DEBUG GlucosePlugin:508 - getDefault() - end
05:04:41,093 DEBUG GlucosePlugin:761 - getDatabasePreference() - start
05:04:41,094 DEBUG GlucosePlugin:765 - getDatabasePreference() - end
05:04:41,095 DEBUG GlucosePlugin:504 - getDefault() - start
05:04:41,095 DEBUG GlucosePlugin:508 - getDefault() - end
05:04:41,099 DEBUG GlucosePlugin:761 - getDatabasePreference() - start
05:04:41,100 DEBUG GlucosePlugin:765 - getDatabasePreference() - end
05:04:41,100 INFO HibernateUtil:83 - Fell through to default configuration
05:04:41,102 INFO Configuration:1426 - configuring from resource: /hibernate.cfg.xml
05:04:41,102 INFO Configuration:1403 - Configuration resource: /hibernate.cfg.xml
Warning: Caught exception attempting to use SAX to load a SAX XMLReader
Warning: Exception was: java.lang.ClassNotFoundException: org/apache/xerces/parsers/SAXParser
Warning: I will print the stack trace then carry on using the default SAX parser
java.lang.ClassNotFoundException: org/apache/xerces/parser[/color]s/SAXParser
at org.xml.sax.helpers.XMLReaderFactory.loadClass(XMLReaderFactory.java:189)
at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(XMLReaderFactory.java:150)
at org.dom4j.io.SAXHelper.createXMLReader(SAXHelper.java:83)
at org.dom4j.io.SAXReader.createXMLReader(SAXReader.java:894)
at org.dom4j.io.SAXReader.getXMLReader(SAXReader.java:715)
at org.dom4j.io.SAXReader.read(SAXReader.java:435)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1484)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1428)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1414)
at edu.utah.cdmcc.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:84)
at database.tests.TestSchemaCreateUpdateJUnit4.setUp(TestSchemaCreateUpdateJUnit4.java:65)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.junit.internal.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAfterRunner.java:74)
at org.junit.internal.runners.BeforeAndAfterRunner.runBefores(BeforeAndAfterRunner.java:50)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:33)
at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
05:04:41,123 ERROR HibernateUtil:101 - Building SessionFactory failed.
org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1494)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1428)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1414)
at edu.utah.cdmcc.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:84)
at database.tests.TestSchemaCreateUpdateJUnit4.setUp(TestSchemaCreateUpdateJUnit4.java:65)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.junit.internal.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAfterRunner.java:74)
at org.junit.internal.runners.BeforeAndAfterRunner.runBefores(BeforeAndAfterRunner.java:50)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:33)
at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.dom4j.DocumentException: SAX2 driver class org.apache.xerces.parsers.SAXParser not found Nested exception: SAX2 driver class org.apache.xerces.parsers.SAXParser not found
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1484)
... 24 more