[jdom-interest] SAXBuilder issues

Jason Hunter jhunter at collab.net
Tue Jun 26 17:08:46 PDT 2001


It's possible you have an older org.apache.xerces.parsers.SAXParser
being found which doesn't implement XMLReader, since it's the cast to
XMLReader that's failing.  That's just a wild guess tho.

Around line 392 of SAXBuilder check what object is returned, what type
it is, and if it's instanceof XMLReader.  It seems weird that a
getXMLReader() call might return a non-XMLReader, but if the classpath
is sufficiently screwy I suppose anything's possible.

-jh-

Krishnan Anantheswaran wrote:
> 
> Hi,
> 
> I have a utility class that uses a SAXBuilder to build
> a JDOM tree. This works fine. I have a JUnit test case
> for it and this works fine thru command line "ant" as
> well.
> 
> Now when I try to execute the ant task from the
> NetBeans IDE, I get an error in building with the root
> cause as a class cast exception.
> 
> I changed the utility class to use a DOMBuilder
> instead of a SAXBuilder and everything works from all
> places.
> 
> My suspicion is that there is some classloader issue
> but for the life of me I'm not able to get it to work
> with the SAXBuilder. Any pointers?
> 
> I'm using the latest JDOM sources from CVS. Stack
> trace follows.
> 
> Regards,
> Krishnan
> 
> org.jdom.JDOMException: Error in building:
> org.apache.xerces.parsers.SAXParser
>         at
> org.jdom.input.SAXBuilder.build(SAXBuilder.java:306)
>         at
> org.jdom.input.SAXBuilder.build(SAXBuilder.java:583)
>         at
> com.vitalect.util.XmlPath.loadXml(XmlPath.java:412)
>         at
> com.vitalect.util.StateMgr.newInstance(StateMgr.java:275)
>         at
> com.vitaltest.util.StateMgrTest.testValidXmlLoad(StateMgrTest.java:73)
>         at java.lang.reflect.Method.invoke(Native
> Method)
>         at
> junit.framework.TestCase.runTest(TestCase.java:156)
>         at
> junit.framework.TestCase.runBare(TestCase.java:130)
>         at
> junit.framework.TestResult$1.protect(TestResult.java:106)
>         at
> junit.framework.TestResult.runProtected(TestResult.java:124)
>         at
> junit.framework.TestResult.run(TestResult.java:109)
>         at
> junit.framework.TestCase.run(TestCase.java:121)
>         at
> junit.framework.TestSuite.runTest(TestSuite.java:160)
>         at
> junit.framework.TestSuite.run(TestSuite.java:155)
>         at
> junit.framework.TestSuite.runTest(TestSuite.java:160)
>         at
> junit.framework.TestSuite.run(TestSuite.java:155)
>         at
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:209)
>         at
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeInVM(JUnitTask.java:409)
>         at
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:283)
>         at
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:263)
>         at
> org.apache.tools.ant.Target.execute(Target.java:153)
>         at
> org.apache.tools.ant.Project.runTarget(Project.java:898)
>         at
> org.apache.tools.ant.Project.executeTarget(Project.java:536)
>         at
> org.apache.tools.ant.Project.executeTargets(Project.java:510)
>         at
> org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:263)
>         at
> org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:118)
> Root cause: java.lang.ClassCastException:
> org.apache.xerces.parsers.SAXParser
>         at
> org.jdom.input.SAXBuilder.createParser(SAXBuilder.java:392)
>         at
> org.jdom.input.SAXBuilder.build(SAXBuilder.java:283)
>         at
> org.jdom.input.SAXBuilder.build(SAXBuilder.java:583)
>         at
> com.vitalect.util.XmlPath.loadXml(XmlPath.java:412)
>         at
> com.vitalect.util.StateMgr.newInstance(StateMgr.java:275)
>         at
> com.vitaltest.util.StateMgrTest.testValidXmlLoad(StateMgrTest.java:73)
>         at java.lang.reflect.Method.invoke(Native
> Method)
>         at
> junit.framework.TestCase.runTest(TestCase.java:156)
>         at
> junit.framework.TestCase.runBare(TestCase.java:130)
>         at
> junit.framework.TestResult$1.protect(TestResult.java:106)
>         at
> junit.framework.TestResult.runProtected(TestResult.java:124)
>         at
> junit.framework.TestResult.run(TestResult.java:109)
>         at
> junit.framework.TestCase.run(TestCase.java:121)
>         at
> junit.framework.TestSuite.runTest(TestSuite.java:160)
>         at
> junit.framework.TestSuite.run(TestSuite.java:155)
>         at
> junit.framework.TestSuite.runTest(TestSuite.java:160)
>         at
> junit.framework.TestSuite.run(TestSuite.java:155)
>         at
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:209)
>         at
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeInVM(JUnitTask.java:409)
>         at
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:283)
>         at
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:263)
>         at
> org.apache.tools.ant.Target.execute(Target.java:153)
>         at
> org.apache.tools.ant.Project.runTarget(Project.java:898)
>         at
> org.apache.tools.ant.Project.executeTarget(Project.java:536)
>         at
> org.apache.tools.ant.Project.executeTargets(Project.java:510)
>         at
> org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:263)
>         at
> org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:118)
> 
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com



More information about the jdom-interest mailing list