Xerces parser error in applet
Written by coregps on Friday, January 27th, 2006 in Java.
If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!
I’m using Mapxtreme for Java 4.7.1 with JDK 1.5 and Tomcat 5.5.7 on Windows 2000 Server and I developed a mapxtreme for java applet, in this applet I defined two public methods. One is used to create the contour annotation layer, the other is used to search the point features covered by the region on the contour layer. This applet runs perfectly in applet viewer. However, when I invoked the second method using javascript in jsp page, I got the following exception:
java.lang.RuntimeException: org.jdom.JDOMException: Could not load org.apache.xerces.parsers.SAXParser: SAX2 driver class org.apache.xerces.parsers.SAXParser not found: org/apache/xerces/parsers/SAXParser
at com.mapinfo.xmlprot.mxtj.bm.createRendition(Unknown Source)
at com.mapinfo.xmlprot.mxtj.bm.createRendition(Unknown Source)
at com.mapinfo.util.bi.createRendition(Unknown Source)
at com.mapinfo.dp.util.msf.cl.b(Unknown Source)
at com.mapinfo.dp.util.msf.cl.getNextFeature(Unknown Source)
at com.mapinfo.dp.util.RewindableFeatureSet.getNextFeature(Unknown Source)
at SimpleMap.drawContour(SimpleMap.java:707)
at SimpleMap.contour(SimpleMap.java:411)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.plugin.javascript.JSInvoke.invoke(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.plugin.javascript.JSClassLoader.invoke(Unknown Source)
at sun.plugin.com.MethodDispatcher.invoke(Unknown Source)
at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)
at sun.plugin.com.DispatchImpl$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin.com.DispatchImpl.invoke(Unknown Source)
I thought it must be the problem of classloader. I tried to put the jar files xercexImpl.jar, xml-apis.jar, jdom.jar, xalan.jar in all of the following directories:
Applet directory
Tomcat/Common/lib
Tomcat/Common/endorsed
myApp/WEB-INF/lib
But no luck. Finally, I found the solution at the Apache Xerces site. Just create a directory named “endorsed” under JRE/lib directory and copy the jar file “xercesImpl.jar” to this directory. This operation is to override the JAXP implementation in JDK1.4 and above. However, Putting this JAR to another location like lib/ext WILL NOT WORK. After doing this, my applet works fine. You can visit http://java.sun.com/j2se/1.5.0/docs/guide/standards/ for more information.
Here, I also want to thank Roel De Nijs for his kindly help!










