You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Roel <di...@scarlet.be> on 2007/11/28 17:29:46 UTC

fop remains active

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: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: fop remains active

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Ok, but undeploying is a web container function. I'd rather ask on the
Tomcat list if anyone has an idea what could cause this. I, for one,
have no idea.

Jeremias Maerki



On 29.11.2007 02:23:02 Roel wrote:
> 
> 
> 
> cbowditch wrote:
> > 
> > 
> > 
> > I don't think this has anything to do with FOP, but could be wrong. It 
> > would certainly help people to answer your question if you told us:
> > 
> > 1) Which web container you deployed your servlet in.
> > 2) How you achieve the "undeploy" of the servlet?
> > 
> > <snip/>
> > 
> > Chris
> > 
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> > 
> > 
> > 
> 
> With web container i assume you mean what kind of server i use: Apache
> Tomcat 6.0. The code in the post is called directly in the doGet of direct
> extension of the httpServlet class.
> 
> I don't achieve the undeployment of the servlet in its own, but with the
> entire application context. I use the manager inlcuded in apache tomcat for
> that. 
> 
> The thing is that the problem only occurs when I actually use the servlet
> that uses fop. That is why I concluded it had something to do with fop.
> 
> Roel
> -- 
> View this message in context: http://www.nabble.com/fop-remains-active-tf4889533.html#a14017492
> Sent from the FOP - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: fop remains active

Posted by Chris Bowditch <bo...@hotmail.com>.
Roel wrote:

> 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 don't think this has anything to do with FOP, but could be wrong. It 
would certainly help people to answer your question if you told us:

1) Which web container you deployed your servlet in.
2) How you achieve the "undeploy" of the servlet?

<snip/>

Chris



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: fop remains active

Posted by Roel <di...@scarlet.be>.


cbowditch wrote:
> 
> 
> 
> I don't think this has anything to do with FOP, but could be wrong. It 
> would certainly help people to answer your question if you told us:
> 
> 1) Which web container you deployed your servlet in.
> 2) How you achieve the "undeploy" of the servlet?
> 
> <snip/>
> 
> Chris
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
> 
> 

With web container i assume you mean what kind of server i use: Apache
Tomcat 6.0. The code in the post is called directly in the doGet of direct
extension of the httpServlet class.

I don't achieve the undeployment of the servlet in its own, but with the
entire application context. I use the manager inlcuded in apache tomcat for
that. 

The thing is that the problem only occurs when I actually use the servlet
that uses fop. That is why I concluded it had something to do with fop.

Roel
-- 
View this message in context: http://www.nabble.com/fop-remains-active-tf4889533.html#a14017492
Sent from the FOP - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org