JDK 1.4 + ANT -> java.lang.NoClassDefFoundError: org/xml/sax/ext/Locator2Impl

I use JDk1.6, and ANT 1.8 normally with no problem.

But, today when I compile a old project using JDK1.4, then the ANT give me Exception

C:\projects\Smartone\sv-jupiter>call ant -version
Apache Ant version 1.6.4 compiled on May 19 2005
Buildfile: build.xml

BUILD FAILED
java.lang.NoClassDefFoundError: org/xml/sax/ext/Locator2Impl
at org.apache.xerces.jaxp.SAXParserImpl.(Unknown Source)
at org.apache.xerces.jaxp.SAXParserFactoryImpl.newSAXParser(Unknown Source)
at org.apache.tools.ant.util.JAXPUtils.newSAXParser(JAXPUtils.java:205)
at org.apache.tools.ant.util.JAXPUtils.getNamespaceXMLReader(JAXPUtils.java:163)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:193)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:140)
at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:91)
at org.apache.tools.ant.Main.runBuild(Main.java:653)
at org.apache.tools.ant.Main.startAnt(Main.java:187)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)

Total time: 0 seconds
java.lang.NoClassDefFoundError: org/xml/sax/ext/Locator2Impl
at org.apache.xerces.jaxp.SAXParserImpl.(Unknown Source)
at org.apache.xerces.jaxp.SAXParserFactoryImpl.newSAXParser(Unknown Source)
at org.apache.tools.ant.util.JAXPUtils.newSAXParser(JAXPUtils.java:205)
at org.apache.tools.ant.util.JAXPUtils.getNamespaceXMLReader(JAXPUtils.java:163)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:193)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:140)
at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:91)
at org.apache.tools.ant.Main.runBuild(Main.java:653)
at org.apache.tools.ant.Main.startAnt(Main.java:187)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
org/xml/sax/ext/Locator2Impl

It likely a XML parser problem (Xerces ?).
Then I try to run the ant will ANT_OPTS=-verbose (to start the java verbose mode), seem jre try to use the XML parse build in, in stead of the Xerces which bundle at ANT.

To solve it,
0/ create folder %ANT_HOME%/endorse
1/ Copy the Xerces related file (xercesImpl.jar, xml-apis.jar), from %ANT_HOME%/lib to %ANT_HOME%/endorse
2/ set environment variable as


set ANT_OPTS=-Djava.endorsed.dirs="%ANT_HOME%\endorse"

Then run again, it OK, and it using the Xerces at %ANT_HOME%\endorse

51 comments to JDK 1.4 + ANT -> java.lang.NoClassDefFoundError: org/xml/sax/ext/Locator2Impl

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>