xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Fournier,Danny [NCR]" <Danny.Fourn...@ec.gc.ca>
Subject Embedding FOP: error with FopFactory
Date Fri, 29 Feb 2008 20:07:40 GMT
I'm having issues calling the FopFactory.newInstance() method.

It's basically a cut and paste from the example I found on Apache's site

-- Error --
ROOT CAUSE: 
java.lang.NoClassDefFoundError: org/apache/xmlgraphics/util/Service
	at
org.apache.fop.util.ContentHandlerFactoryRegistry.discover(ContentHandle
rFactoryRegistry.java:102)
	at
org.apache.fop.util.ContentHandlerFactoryRegistry.<init>(ContentHandlerF
actoryRegistry.java:47)
	at org.apache.fop.apps.FopFactory.<init>(FopFactory.java:75)
	at
org.apache.fop.apps.FopFactory.newInstance(FopFactory.java:165)
	at MyFop.render(MyFop.java:75)


-- Code --
public void render(){
        try {
           
            // configure fopFactory as desired
75: 		FopFactory fopFactory = FopFactory.newInstance();

            FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
            // configure foUserAgent as desired

            // Setup output
            OutputStream out = new java.io.FileOutputStream(this.pdf);
            out = new java.io.BufferedOutputStream(out);
            
           	try {
                // Construct fop with desired output format
                Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF,
foUserAgent, out);
    
                // Setup XSLT
                TransformerFactory factory =
TransformerFactory.newInstance();
                Transformer transformer = factory.newTransformer(new
StreamSource(this.xslt));
                
                // Set the value of a <param> in the stylesheet
                transformer.setParameter("versionParam", "2.0");
            
                // Setup input for XSLT transformation
                Source src = new StreamSource(this.xml);
            
                // Resulting SAX events (the generated FO) must be piped
through to FOP
                Result res = new SAXResult(fop.getDefaultHandler());
    
                // Start XSLT transformation and FOP processing
                transformer.transform(src, res);
            } finally {
                out.close();
            }
            
            System.out.println("Success!");
        } catch (Exception e) {
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }	

Dan

Mime
View raw message