You must be using Tomcat in "exploded" mode (in your server.xml, your Context's "docBase" attribute references a directory rather than a .war file)?
In "unexploded" mode, Tomcat still unpacks the WAR file, but "ServletContext.getRealPath(..)" always returns null, as per the J2EE spec. Unfortunately we have to support both modes of operation... -----Original Message----- From: Stuart McGrigor [mailto:[EMAIL PROTECTED] Sent: 15 April 2005 13:57 To: [email protected] Subject: Re: Using "external-graphic" in a Servlet Container? I'm using Tomcat as well...I just set the baseDir config property (and the fontBaseDir as well) like this: baseDir = request.getSession().getServletContext().getRealPath(""); org.apache.fop.configuration.Configuration.put("baseDir", baseDir); org.apache.fop.configuration.Configuration.put("fontBaseDir", baseDir + "/fonts"); try { File userConfigFile = new File(baseDir + "/fopConfig.xml"); Options options = new Options(userConfigFile); } catch (FOPException ex) { log.error("Configuring FOP - Exception:" + ex.toString()); } and then I can use my normal collection of strange fonts, and external-graphic works with paths that're relative to wherever Tomcat unpacked the WAR file to. Stuart "Hassan-Zadeh, Martin" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > HI Chris, > > I am using also tomcat and if you put the file into the for example > the WEB-INF directory and use /WEB-INF/foo.jpg it works fine for me. > I aggree that it would be nice if this feature was there ( that's what > I tried to say with the spec and URI since ). > The solution you described would be really since it would solve my > problem of dynamical generated pictures that I want to include in a > FOP generated PDF. > Maybe somebody out there has some time at the moment to contribute > such peace of code. > > Kind Regards > > Martin > > -----Original Message----- > From: Chris Nappin [mailto:[EMAIL PROTECTED] > Sent: Dienstag, 12. April 2005 16:56 > To: Hassan-Zadeh, Martin; [email protected] > Subject: RE: Using "external-graphic" in a Servlet Container? > > > Hi Martin, > > In Tomcat, ServletContext.getRealPath("what ever you path is") > returns null if running from a .war file, even though it expands the > files locally. However I'm working on a product that must run in lots > of different app servers, so it must work in unexpanded mode anyway. > > I don't see why this shouldn't be possible just because the XSL-FO > spec uses URIs? DTDs are defined using a URI, and JAXP handles this > fine (using URIResolver and <ServletContext>.getResourceAsStream(...), > as I mentioned below). > > I guess FOP needs extending to add something similar to the URIResolver. > Not sure I'm going to have time to contribute such code myself ;-( > > Cheers, > > Chris. > > -----Original Message----- > From: Hassan-Zadeh, Martin > [mailto:[EMAIL PROTECTED] > Sent: 12 April 2005 15:33 > To: '[email protected]' > Cc: Chris Nappin > Subject: RE: Using "external-graphic" in a Servlet Container? > > Hi Chris, > > My experience is no. > I had a similar problem, but finally had to solve it by creating and > acessing files in an expanded war file. > I have taken a look in the code and it is opening new connection via > the URL class which can not be parametrized or changed from outside. > I think this is a design feature /issue because the XSL FO > specification is only taking about a uri specification that must be > used as src in an external-graphic element. > Have you tried ServletContext.getRealPath("what ever you path is") ? > Maybe you servlet container ( like weblogic and others ) expands your > war automatically in a temp dir,which would than solve your problem ? > If you find another solution let me know ! > > Kind Regards > > Martin > > -----Original Message----- > From: Chris Nappin [mailto:[EMAIL PROTECTED] > Sent: Dienstag, 12. April 2005 16:18 > To: [email protected] > Subject: Using "external-graphic" in a Servlet Container? > > > Hi, > > I'm trying to use FOP to dynamically generate PDF documents from > within a servlet container. > > Is there any way of using "external-graphic" to include a static file > (within my web application) in the PDF output, without having the FOP > Driver perform a full HTTPS request (slow, inefficient, difficult to > configure) for applications deployed as an un-expanded WAR file (i.e. > have no access to the local file system). > > For example, to do this sort of thing in an XSLT transformation, I > simply create a "URIResolver" class which can use > <ServletContext>.getResourceAsStream(...) > > Regards > > Chris Nappin > Senior Analyst Programmer > > ABM United Kingdom Limited > Telephone: +44 (0) 115 977 6999 > Facsimile: +44 (0) 115 977 6850 > Web: http://www.abm-uk.com <http://www.abm-uk.com/> > > ABM for Intelligent Solutions > > > > CONFIDENTIALITY NOTICE > > This e-mail is confidential to the addressee. It may also be privileged. > Neither the confidentiality nor any privilege attaching to this e-mail > is waived lost or destroyed by reason that it has been mistakenly > transmitted to a person or entity other than the addressee. If you are > not the addressee please notify us immediately by telephone or fax at > the numbers provided above or e-mail by Reply To Author and return the > printed e-mail to us by post at our expense. We believe, but do not > warrant, that this e-mail and any attachments are virus-free, but you > should check. We may monitor traffic data of both business and > personal e-mails. We are not liable for any opinions expressed by the > sender where this is a non-business e-mail. If you do not receive all > the message, or if you have difficulty with the transmission, please > telephone us immediately. > > > > CONFIDENTIALITY NOTICE > > This e-mail is confidential to the addressee. It may also be privileged. > Neither the confidentiality nor any privilege attaching to this e-mail > is waived lost or destroyed by reason that it has been mistakenly > transmitted to a person or entity other than the addressee. If you are > not the addressee > please notify us immediately by telephone or fax at the numbers > provided above or e-mail by Reply To Author and return the printed > e-mail to us by post at our expense. We believe, but do not warrant, > that this e-mail and any attachments are virus-free, but you should > check. We may monitor traffic > data of both business and personal e-mails. We are not liable for any > opinions expressed by the sender where this is a non-business e-mail. > If you > do not receive all the message, or if you have difficulty with the > transmission, please telephone us immediately. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] CONFIDENTIALITY NOTICE This e-mail is confidential to the addressee. It may also be privileged. Neither the confidentiality nor any privilege attaching to this e-mail is waived lost or destroyed by reason that it has been mistakenly transmitted to a person or entity other than the addressee. If you are not the addressee please notify us immediately by telephone or fax at the numbers provided above or e-mail by Reply To Author and return the printed e-mail to us by post at our expense. We believe, but do not warrant, that this e-mail and any attachments are virus-free, but you should check. We may monitor traffic data of both business and personal e-mails. We are not liable for any opinions expressed by the sender where this is a non-business e-mail. If you do not receive all the message, or if you have difficulty with the transmission, please telephone us immediately. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
