Description
We have a web-application using Apache FOP. When we generate PDF files containing SVG graphics, we get an exception:
java.lang.ClassNotFoundException: org.w3c.dom.svg.SVGDocument org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547) org.apache.tomee.catalina.LazyStopWebappClassLoader.loadClass(LazyStopWebappClassLoader.java:109) java.lang.ClassLoader.defineClass1(Native Method) java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) java.lang.ClassLoader.defineClass(ClassLoader.java:615) java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2918) org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1174) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1669) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547) org.apache.tomee.catalina.LazyStopWebappClassLoader.loadClass(LazyStopWebappClassLoader.java:109) org.apache.batik.dom.svg.SVGDOMImplementation.createDocument(Unknown Source) org.apache.fop.fo.extensions.svg.SVGDOMContentHandlerFactory$Handler.startElement(SVGDOMContentHandlerFactory.java:128) org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:306) org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:175) org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1073) org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source) org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source) org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) org.apache.xerces.parsers.XMLParser.parse(Unknown Source) org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:485) org.apache.fop.servlet.FopServlet.render(FopServlet.java:244) org.apache.fop.servlet.FopServlet.renderFO(FopServlet.java:183) org.apache.fop.servlet.FopServlet.doGet(FopServlet.java:120) javax.servlet.http.HttpServlet.service(HttpServlet.java:621) javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
We have traced the problem down to a class called "org.apache.openejb.util.classloader.URLClassLoaderFirst".
In the method "public static boolean shouldSkip(final String name)" you simply check if the classname starts with "org.w3c.dom", and if so - you delegate the loading of the class to the parent classloader. Since the "org.w3c.dom.svg" classes is not part of Tomee, this will of course result in the exception above.
The workaround for us in this case was to apply the system-property:
openejb.classloader.forced-load=org.w3c.dom.svg,org.w3c.dom.smil,org.w3c.css,org.w3c.dom.events
It would be desired if these kind of classes would be loaded from the Web-app without having to apply this property. Alternatively you need to include all sub-API's for packages that you force being loaded by the parent class loader.
This seems to be a behavior change compared to 1.5.x.