Hi All,

One of our applications is using FOP processing mechanism to transform xml
files to pdf format by applying XSLT templates. The issue here is (which has
become a show stopper now) is that at times the transformation process kills
the server on which it is running. This happens randomly for different
servers. There is no specific scenario in which it can be replicated. As
evident from server logs, it fails at the following line 
transformer.transform(src, res);

Please find below the code snippet. Any suggestions to fix the issue are
greatly appreciated. 

/// import statements


import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.OutputStream;

import javax.xml.transform.OutputKeys;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

// Code snippet follows:


                        XmlDocument receiptDataXML = new XmlDocument();
                        JavaXMLBinding.java2XML(receiptDataPOJO, 
receiptDataXML);

                        File xsltfile=new File(xsltPath + "testxsl.xsl");
                         
                        File pdffile = new File(xmlPath + "testpdf.pdf");

                        // Setup output

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

                        FopFactory fopFactory = FopFactory.newInstance();
                        fopFactory.setUserConfig(configfile);
                        FOUserAgent foUserAgent =
fopFactory.newFOUserAgent();

                        // Construct fop with output format as PDF
                        Fop fop = 
fopFactory.newFop(MimeConstants.MIME_PDF,foUserAgent, out);

                        TransformerFactory factory = 
TransformerFactory.newInstance();
                        Transformer transformer = factory.newTransformer(new
StreamSource(xsltfile));
                        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
                                
                        java.io.StringWriter wr=new java.io.StringWriter();
                        receiptDataXML.write(wr);
                        ByteArrayInputStream xmlInputStream = new      
ByteArrayInputStream(wr.toString().getBytes ());
                        Source src = new StreamSource(xmlInputStream);
                                                                
                        // 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);







-- 
View this message in context: 
http://www.nabble.com/Abrubt-server-shutdown-during-XSLT-transformation-using-FOP-0.94-tp18864628p18864628.html
Sent from the FOP - Users mailing list archive at Nabble.com.


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

Reply via email to