Fop исключение, когда FopFactory.newInstance ()

Я использую распорки 2 и яЯ пытаюсь использовать FOP для создания PDF-файлов из XML и XSL. Я разрабатываю мой код в базе этих двух URLhttp://svn.apache.org/viewvc/xmlgraphics/fop/trunk/examples/embedding/java/embedding/ExampleXML2PDF.java?view=markup а такжеhttp://justcode.wordpress.com/2009/01/16/generare-pdf-con-struts2-fop-xml-e-xslt/

Вот'мой код, яя пытаюсь использовать два разных способа

public class JspToPdfTest extends ActionSupport{

private InputStream inputStream;
private Xml2PdfManager xml2PdfManager;

public InputStream getInputStream() {
    return inputStream;
}
public void setInputStream(InputStream inputStream) {
    this.inputStream = inputStream;
}   
public JspToPdfTest(){
    xml2PdfManager = new Xml2PdfManager();
}

public String doPrint()  {
    String xml = "C:\\Users\\Administrator\\workspace\\path\\actions\\forms\\testeFOPxml.xml";
    String xslPath = "C:\\Users\\Administrator\\workspace\\path\\actions\\forms\\xml2fo.xsl";
    InputStream xmlInput = new ByteArrayInputStream(xml.getBytes());

    ByteArrayOutputStream out = (ByteArrayOutputStream) xml2PdfManager.convertXML2PDF(xmlInput, new File(xslPath));

    inputStream = new ByteArrayInputStream(out.toByteArray());
    return SUCCESS;
}

public String xmlToPdf() {
                try {
                    System.out.println("FOP ExampleXML2PDF\n");
                    System.out.println("Preparing...");

                    File baseDir = new File("C:\\Users\\Administrator\\workspace\\path\\actions\\forms\\");
                    File outDir = new File(baseDir, "out");
                    outDir.mkdirs();

                    File xmlfile = new File(baseDir, "testeFOPxml.xml");
                    File xsltfile = new File(baseDir, "xml2fo.xsl");
                    File pdffile = new File(outDir, "ResultXML2PDF.pdf");

                    final FopFactory fopFactory = FopFactory.newInstance();

                    FOUserAgent foUserAgent = fopFactory.newFOUserAgent();

                    OutputStream out = new java.io.FileOutputStream(pdffile);
                    out = new java.io.BufferedOutputStream(out);

                    try {
                        Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);

                    TransformerFactory factory = TransformerFactory.newInstance();
                    Transformer transformer = factory.newTransformer(new StreamSource(xsltfile));

                        transformer.setParameter("versionParam", "2.0");

                        Source src = new StreamSource(xmlfile);

                        Result res = new SAXResult(fop.getDefaultHandler());

                        transformer.transform(src, res);
                    } finally {
                        out.close();
                    }
                } catch (Exception e) {
                e.printStackTrace(System.err);
                    System.exit(-1);
                }
            return SUCCESS;
            }
}

и действие struts.xml

 -->
         
            application/pdf
            filename="dom.pdf" 
            1024 
         
         
    

    
        
            application/pdf
            filename="dom.pdf"
            1024
        
        
    

В конце концов, метод xml2PdfManager.convertXML2PDF:

public OutputStream convertXML2PDF(InputStream xml, File xsl) {
    ByteArrayOutputStream out = new ByteArrayOutputStream();

    FopFactory fopFactory = FopFactory.newInstance();

    TransformerFactory tFactory = TransformerFactory.newInstance();

    try {
    Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out);

    Source src = new StreamSource(xml);

    Source xsltSrc = new StreamSource(xsl);
    Transformer transformer = tFactory.newTransformer(xsltSrc);

    Result res = new SAXResult(fop.getDefaultHandler());
    transformer.transform(src, res);
    } catch (Exception e) {
        e.printStackTrace(System.err);
    }
    return out;
    }

в обеих ситуациях яу нас есть:

java.lang.NoSuchMethodError:     
org.apache.xmlgraphics.util.Service.providerNames(Ljava/lang/Class;)Ljava/util/Iterator; 

когда я делаю FopFactory.newInstance ();

Любое предложение, чтобы помочь мне было бы здорово !!

Ответы на вопрос(1)

Ваш ответ на вопрос