Very little to work with here. If you have a code line I'm sure you also
have an exception and a stack trace. Can we see that please? If it's a
JVM crash there's not much we can help you with but you don't say if
it's that, either.

The code snippet is out of context which doesn't help either. Anyway,
looking at the code I see two things that I don't like (but that doesn't
mean it has something to do with your problem:
1. That the XML generated from the POJO has to be written to a temporary
String is very inefficient. I don't know what you're using there but
there has to be a better way (i.e. to connect via SAX).
2. The FopFactory and the TransformerFactory are instantiated for every
processing run. That way you can't profit from caching images and other
stuff and the stylesheet has to be reparsed every time. That slows your
application down if nothing else. If this code is running concurrently
you might easily get into an OutOfMemoryError if larger images are used
because they can't be shared and take up space for each processing run
rather than once. Sharing the FopFactory doesn't get that out of the
world but can improve the situation.

On 07.08.2008 08:05:40 xsltuser wrote:
> 
> 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.
> 
> 



Jeremias Maerki


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

Reply via email to