FOP fails with java.lang.ClassNotFoundException: org.w3c.dom.svg.SVGDocument

Bug #268930 reported by Raphael Bosshard
2
Affects Status Importance Assigned to Milestone
fop (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: fop

If a .fo file contains SVG images, it will fail with following error:

Exception in thread "main" java.lang.NoClassDefFoundError: org/w3c/dom/svg/SVGDocument
 at java.lang.ClassLoader.defineClass1(Native Method)
 at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
 at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
 at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
 at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
 at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
 at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
 at org.apache.batik.dom.svg.SVGDOMImplementation.createDocument(Unknown Source)
 at org.apache.fop.fo.extensions.svg.SVGElement.init(SVGElement.java:176)
 at org.apache.fop.fo.extensions.svg.SVGElement.processNode(SVGElement.java:78)
 at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:320)
 at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:185)
 at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1073)
 at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
 at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
 at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
 at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
 at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
 at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
 at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
 at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
 at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:485)
 at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:165)
 at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:115)
 at org.apache.fop.cli.Main.startFOP(Main.java:166)
 at org.apache.fop.cli.Main.main(Main.java:197)
Caused by: java.lang.ClassNotFoundException: org.w3c.dom.svg.SVGDocument
 at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
 at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

The class 'org.w3c.dom.svg.SVGDocument' can be found in xml-apis-ext.jar, but since this JAR is not defined in the classpath created by the loader '/usr/bin/fop', FOP will fail.

Revision history for this message
Raphael Bosshard (raphael.bosshard) wrote :
description: updated
Revision history for this message
Raphael Bosshard (raphael.bosshard) wrote :

'xml-apis-ext.jar' is installed through the package 'libxml-commons-external-java', which is installed by 'libbatik-java', which in turn is required for the 'fop' package, so the patch should work in any case.

Changed in fop:
assignee: nobody → onkarshinde
Changed in fop:
assignee: onkarshinde → nobody
status: New → Confirmed
Revision history for this message
James Westby (james-w) wrote :

Hi,

Shouldn't you also add a dependency on libxml-commons-external-java?

While it may be installed by a dependency chain currently if you use it you
should depend on it.

Thanks,

James

Revision history for this message
Onkar Shinde (onkarshinde) wrote :
Revision history for this message
Onkar Shinde (onkarshinde) wrote :

@Raphael,

Is it possible for you to provide some test document to quickly verify the fix?

Revision history for this message
Onkar Shinde (onkarshinde) wrote :

Please find attached sample docbook xml which embeds an SVG image. The error is reproducible with current version of fop in intrepid.

I then modified the /usr/bin/fop to include appropriate jar file in classpath and the error is not present anymore.

The command for converting from xml to pdf is -
$ fop -xml sample.xml -xsl /usr/share/xml/docbook/stylesheet/nwalsh/fo/docbook.xsl -pdf sample.pdf

Revision history for this message
Scott Kitterman (kitterman) wrote :

Ack from motu-release.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package fop - 1:0.94.dfsg-2ubuntu2

---------------
fop (1:0.94.dfsg-2ubuntu2) intrepid; urgency=low

  * debian/control
    - Add build and runtime dependency libxml-commons-external-java.
  * debian/fop.sh
    - Add xml-apis-ext.jar in classpath. Thanks Raphael Bosshard for pointing
      out. (LP: #268930)

 -- Onkar Shinde <email address hidden> Sun, 19 Oct 2008 23:46:06 +0530

Changed in fop:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.