Hello all,

Sorry to start my first post off with a question but here goes:

java.lang.NoSuchMethodError: org.apache.fop.apps.Fop.<init>(I)V

is the exception I recieve when I try and run FOP within my WebApp
running on JBoss.  Specifically it happens on this line of code:

            Fop fop = new Fop(Fop.RENDER_PDF);

I have rtfm'ed and googled for this and the closest postings I can see
point to a classpath issue.  I have made sure to replace the libraries
in my WebApp's lib directory with the three jars listed below, the
commons logging, commons io, avalon framework and the fop.jar I built.
 And yes, I made sure to remove the old versions of these libraries.

I am using FOP straight out of CVS from yesterday (09/28/2004).  I
have built a stand alone java app and called the same render method I
have listed below and it works.

The only differences between the method below and the problematic one
in my code is
the System.out's translate to logger.info and the method is not
static.  Other than that it's the same code.

Any insight would be appreciated.

Thanks!

--
Dan Glauser
Roundbox Media
[EMAIL PROTECTED]

java -classpath
".:${PWD}/fop.jar:${PWD}/avalon-framework-4.1.4.jar:${PWD}/commons-logging-1.0.3.jar:${PWD}/commons-io-1.0.jar"
PDFMaker simple.fo simple.pdf

    /**
     * Renders an FO document to a PDF.  Returns true if the document was
     * rendered without a problem.
     * @param foFilename The complete path (and filename) of the FO Document.
     * @param pdfFilename The complete path (and filename) of the generated PDF.
     * @return A boolean relating whether the PDF was successfully
generated or not.
     */
    public static boolean fopRenderVerCurrent(String foFilename,
String pdfFilename)
    {
        boolean rendered = true;

        try
        {
            // Setup source
            System.out.println("Creating the new StreamSource");
            Source foSrc = new StreamSource( new File(foFilename) );
            
            // Setup the identity transformation
            System.out.println("Setting up the identity transformation");
            TransformerFactory transformerFactory = 
TransformerFactory.newInstance();
            Transformer        transformer        =
transformerFactory.newTransformer();
            // Setup FOP
            System.out.println("Creating the Fop object");
            Fop fop = new Fop(Fop.RENDER_PDF);
            System.out.println("Fop object created");

            // Setup output
            FileOutputStream out = new FileOutputStream(pdfFilename);
            System.out.println("Setting the output for the Fop");
            fop.setOutputStream(out);
            
            // Make sure the XSL transformation's result is piped through to FOP
            Result foResult = new SAXResult(fop.getDefaultHandler());
            
            // Start the transformation and rendering process
            System.out.println("Transforming the source to the result");
            transformer.transform(foSrc, foResult);

            // Flush and close the output stream
            System.out.println("Closing the output stream and exiting");
            out.flush();
            out.close();
        }
        catch(java.io.FileNotFoundException ex)
        {
            System.err.println("************ Could not find the fo file:   "
+ foFilename );
            System.err.println("************ Could not print the document: "
+ pdfFilename);
            rendered = false;
        }
        catch(java.io.IOException ex)
        {
            System.err.println("************ Error when writing the pdf
document " + pdfFilename + " to the filesystem");
            System.err.println("Exception: " + ex.getMessage());
            rendered = false;
        }
        catch(org.apache.fop.apps.FOPException ex)
        {
            System.err.println("************ Error when rendering pdf
document " + pdfFilename + " from fo document: " +  foFilename);
            System.err.println("Exception: " + ex.getMessage());
            rendered = false;
        }
        catch(javax.xml.transform.TransformerConfigurationException ex)
        {
            System.err.println("************ Error when configuring the
transform " + pdfFilename + " from fo document: " +  foFilename);
            System.err.println("Exception: " + ex.getMessage());
            rendered = false;
        }
        catch(javax.xml.transform.TransformerException ex)
        {
            System.err.println("************ Error when transforming " +
pdfFilename + " from fo document: " +  foFilename);
            System.err.println("Exception: " + ex.getMessage());
            rendered = false;
        }

        if(rendered == true)
            System.out.println("Document rendered");

        return rendered;
    }

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to