-->
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.  [ 7 posts ] 
Author Message
 Post subject: SAX Parser error when unit testing
PostPosted: Mon Nov 05, 2007 8:44 am 
Beginner
Beginner

Joined: Fri Mar 04, 2005 7:12 pm
Posts: 34
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

_________________
J. Michael Dean, MD


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 05, 2007 9:53 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
HI mdean77

add jaxp.jat in your classpath

_________________
Dharmendra Pandey


Top
 Profile  
 
 Post subject: SAX parser error when unit testing
PostPosted: Mon Nov 05, 2007 5:58 pm 
Beginner
Beginner

Joined: Fri Mar 04, 2005 7:12 pm
Posts: 34
Thanks. Tried to find jaxp.jar and information suggests this has been incorporated into other jars. Then looked at JAXB. But not sure what to do at this point.

Pertinent point that I completely forgot was that upgraded the Macintosh operating system to Leopard. Maybe this is a problem with that JVM.

- Mike

_________________
J. Michael Dean, MD


Top
 Profile  
 
 Post subject: SAX Parser error when unit testing
PostPosted: Mon Nov 05, 2007 9:31 pm 
Beginner
Beginner

Joined: Fri Mar 04, 2005 7:12 pm
Posts: 34
Added the jaxb-impl.jar, jaxb-xjc.jar, and jaxb-api.jar from my jboss distribution, but no effect on the error. jasp.jar does not exist anywhere on my system.

_________________
J. Michael Dean, MD


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 06, 2007 12:36 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
Plz.. send us .class file

_________________
Dharmendra Pandey


Top
 Profile  
 
 Post subject: SAX Parser error when unit testing
PostPosted: Tue Nov 06, 2007 8:15 am 
Beginner
Beginner

Joined: Fri Mar 04, 2005 7:12 pm
Posts: 34
Here is the .classpath file.

Code:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
   <classpathentry kind="src" path="src"/>
   <classpathentry kind="src" path="tests"/>
   <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
   <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
   <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
   <classpathentry kind="con" path="DROOLS/Drools"/>
   <classpathentry kind="output" path="bin"/>
</classpath>


Inside the requiredPlugins referred to above, org.apache.xerces_2.8.0v200705301630.jar is included, and within this jar are accessible modules jaxp/*, jaxp/datatype/*, and jaxp/validation/* . There is also parsers/* in that jar.

Thanks.

_________________
J. Michael Dean, MD


Top
 Profile  
 
 Post subject: Re: SAX Parser error when unit testing
PostPosted: Wed Apr 24, 2013 3:27 pm 
Newbie

Joined: Wed Jun 20, 2012 4:55 pm
Posts: 7
Did you ever fix this?


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