Search code examples
javatomcatjaxbclassloader

javax.xml.bind.DatatypeConverter leaking class loaders?


I am currently investigating some class loader leaks of an application on Tomcat 7 (w/ Oracle JDK 7). One class that keeps a static reference to the web application class loader (and thus causes the class loader not to be released on redeploy/restart) is javax.xml.bind.DatatypeConverter, which lives in the system class loader and keeps a static reference via its theConverter field to com.sun.xml.bind.DatatypeConverterImpl from Sun's jaxb-impl package.

Has anyone ever observed this issue before? Any suggestions (except for using reflection to null the static field on application shutdown)?


Solution

  • As it turned out, one of my dependencies (com.sun.jersey:jersey-json) pulled in com.sun.xml.bind:jaxb-impl, which was responsible for the System Classloader -> Application Classloader reference. Excluding that dependency solved the issue (as JDK 7 comes with a sensible JAXB implementation, which will be referenced within the System CL, which is fine).