Apache FOP java.lang.NoClassDefFoundError

March 13, 2008

This is what typically happens trying to run Apache FOP on Leopard’s default Tomcat:

java.lang.NoClassDefFoundError
  org.apache.fop.fo.expr.NCnameProperty.getColor(NCnameProperty.java:52)
   org.apache.fop.fo.properties.ColorProperty$Maker.convertPropert 
...

The thing that got it running for me was:

nano /Library/Tomcat/bin/tomcat-launchd.sh
export JAVA_OPTS="-Djava.awt.headless=true"

… just before it calls startup.sh. You don’t really notice it, but FOP will actually give an error about not having permissions to use the window server, after which it just keeps dying of that NoClassDefFoundError.

I got it working the last time because I launched another copy of Tomcat from the Terminal within the GUI and didn’t notice a org.apache.tomcat.startup… process had appeared in the dock. :-)