Hi, I have written a simple script to read in an xml file from the command line and convert it to pdf. I have put the script in the FOP/source/fop-0.20.4/src directory. When I run the build script, it compiles okay. However, when I try and run the compiled code it gives me the following error: test:ozhan 510% java RenderingEngine input.xml output.pdf Exception in thread "main" java.lang.NoClassDefFoundError: org/xml/sax/SAXException at RenderingEngine.main(Unknown Source) It appears that the sax library isn't present in my source tree. The code is shown below: ------ import java.io.*; import java.lang.*; import java.util.*; // FOP libraries import org.apache.fop.apps.Driver; import org.apache.fop.apps.Version; import org.apache.fop.messaging.MessageHandler; import org.xml.sax.InputSource; import org.apache.fop.apps.FOPException; import org.apache.avalon.framework.logger.ConsoleLogger; import org.apache.avalon.framework.logger.Logger; class RenderingEngine { public static void main(String args[]) { if (args.length != 2) { System.err.println("Usage: % java RenderingEngine " + "<inputFileName.xml> <outputFileName.pdf>"); System.exit(1); } try { String inFileName = args[0]; String outFileName = args[1]; try { Driver driver = new Driver(new InputSource (inFileName), new FileOutputStream(outFileName)); driver.setRenderer(Driver.RENDER_PDF); driver.run(); Logger logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO); MessageHandler.setScreenLogger(logger); driver.setLogger(logger); } catch (FOPException ex) { //throw new FOPException(ex); System.err.println("ERROR: " + ex); } } catch (IOException exception) { System.err.println(exception); System.exit(1); } } }
I should also point out, the reason for this program is purely to test that I can call FOP libraries from a stand alone application. Once I have this working I can progress onto more advanced tasts I have planned out.
Please don't use Bugzilla for this kind of thing. The fop-user mailing list is better suited for getting help. You're missing the JAXP API in your classpath (xml-apis.jar for example). Have a look at the fop.sh script in the root directory of the FOP distribution for comparison. The command-line option you need to look for is -cp or -classpath. And by the way, you should set up the logger before calling run(). After run() the show is already over. :-) I'm closing this entry. Please follow up on the fop-user mailing list.
batch transition to closed remaining pre-FOP1.0 resolved bugs