When i use fop in a servlet to render an xml doc to pdf and undeploy the
servlet afterwards, parts of the servlet are not removed preventing me from
redeploying it.
The files that remain in the directory are the jar of the batik library and
fop.jar.
Do i need to close something to unload FOP or is this simply a bug?
I use this code:
ByteArrayOutputStream out = new ByteArrayOutputStream();
FopFactory ff=FopFactory.newInstance();
//ff.getRendererFactory().addRendererMaker("org.apache.fop.render.pdf.PDFRendererMaker");
//ff.getXMLHandlerRegistry().addXMLHandler("org.apache.fop.render.pdf.PDFSVGHandler");
TransformerFactory tf=TransformerFactory.newInstance();
StreamSource xslfo=new StreamSource(new
File(this.getServletContext().getRealPath("lid-pdf.xsl")));
try {
Transformer tt=tf.newTransformer(xslfo);
Fop fp=ff.newFop(MimeConstants.MIME_PDF, out);
SAXResult res=new SAXResult(fp.getDefaultHandler());
Source src= new DOMSource(doc);
DOMResult dd=new DOMResult();
assert(src!=null);
assert(res!=null);
tt.transform(src, dd);
Transformer t2=tf.newTransformer();
t2.transform(new DOMSource((Document) dd.getNode()), res );
//Prepare response
response.setContentType("application/pdf");
assert(out.size()>0);
response.setContentLength(out.size());
//Send content to Browser
response.getOutputStream().write(out.toByteArray());
response.getOutputStream().flush();
response.getOutputStream().close();
} catch (FOPException e) {
// TODO Auto-generated catch block
throw new ServletException(e);
} catch (TransformerConfigurationException e1) {
// TODO Auto-generated catch block
throw new ServletException(e1);
} catch (TransformerException e) {
// TODO Auto-generated catch block
throw new ServletException(e);
}
System.gc();
Roel
--
View this message in context:
http://www.nabble.com/fop-remains-active-tf4889533.html#a13995728
Sent from the FOP - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]