XML parsing problem in Tomcat
843834Dec 18 2001 — edited Dec 19 2001I'm finishing up an integration test on a servlet that parses an xml feed using the SAX parser. The servlet works great, except there is a small memory leak. I'm pretty sure I know what the problem is but have little idea how to fix it.
I believe that when my servlet runs, the virtual machine is pulling in Tomcat's XML parsing libs, instead of my own and that is causing the leak. Sounds a little far-fetched, I know, but this is why I think this is the case:
1) I ran into a similar problem a few months ago when creating a stand-alone server designed to parse XML feeds. The server had a memory leak. Come to find out, the cause of this was linking in the wrong XML libs. I can't remember the exact libs ... it was something like putting jaxp.jar and xml.jar in the classpath instead of crimson.jar and xerces.jar. Whatever the wrong jars were, as soon as I specifed crimson.jar and xerces.jar (version 1.4.0) ONLY in the CLASSPATH, the leak went away.
2) My servlet requires crimson.jar and xerces.jar to run. However, if I remove those two jars from the WEB_INF/lib directory, the servlet still runs. So the servlet must be resolving symbol references from some other jar file.
3) I've profiled my servlet with Optimizeit. I couldn't figure out how to run the servlet in the profiler using tomcat, so I followed Optimize it suggestions and ran it with jswdk-1.0.1. I also made sure to set CLASSPATH to crimson.jar and xerces.jar. When run like this, optimizeit shows now memory leak.
So I can only imagine when my servlet runs in tomcat, the wrong xml parsing libs are being linked in at runtime.
So my question is, how can I tell Tomcat to use my libs, and not Tomcat's libs at runtime.
Thanks for any suggestions,
Rich