Hello Andreas,

I've tried to replace the FOPException by SAXException as you said, 
but it didn't work:

 //public void convertFO2PDF(File fo, File pdf) throws IOException, 
FOPException {
    public void convertFO2PDF(File fo, File pdf) throws IOException, 
SAXException {
        fopFactory.setUserConfig(new File("/opt/coolstack/fop/conf/fop.xconf"));

        OutputStream out = null;

        try { ...}

Compilation: www-slave:root>javac ExampleFO2PDF.java
ExampleFO2PDF.java:67: cannot find symbol
symbol  : class SAXException
location: class org.apache.fop.servlet.ExampleFO2PDF
    public void convertFO2PDF(File fo, File pdf) throws IOException, 
SAXException {
                                                                     ^
1 error

The same for the FopServlet.java program from the FOP 0.95 distribution :
In the directory {fop-dir}/src/java/org/apache/fop/servlet

I replaced FOPException by SAXException, and put there the configuration as 
following:
------------------------------------------------------------
vi FopServlet.java

[...]
 protected void configureFopFactory() {
        fopFactory.setUserConfig(new File("/opt/coolstack/fop/conf/fop.xconf"));
        //Subclass and override this method to perform additional configuration
    }

[...]
 protected void renderFO(String fo, HttpServletResponse response)
                //throws FOPException, TransformerException, IOException {
                throws SAXException, TransformerException, IOException {



When I compiled this servlet: javac FopServlet.java
------------------------------------------
I've got error:

FopServlet.java:184: cannot find symbol
symbol  : class SAXException
location: class org.apache.fop.servlet.FopServlet
                throws SAXException, TransformerException, IOException {
                       ^
FopServlet.java:242: cannot find symbol
symbol  : class SAXException
location: class org.apache.fop.servlet.FopServlet
                throws SAXException, TransformerException, IOException {
                       ^
2 errors

Have you got any idea, how to compile the FopServlet.java using a configuration 
?
btw, the FopServlet.java attached to the mail.

thank you,

Al


--- On Tue, 4/21/09, Andreas Delmelle <[email protected]> wrote:

From: Andreas Delmelle <[email protected]>
Subject: Re: FOP in servlet and configuration
To: [email protected]
Date: Tuesday, April 21, 2009, 9:10 AM

On 21 Apr 2009, at 15:50, Al Dancer wrote:

Hi Al

> www-slave:root>javac ExampleFO2PDF.java
> ExampleFO2PDF.java:68: unreported exception org.xml.sax.SAXException; must be 
> caught or declared to be thrown
>         fopFactory.setUserConfig(new 
>File("/opt/coolstack/fop/conf/fop.xconf"));
>                                 ^
> <snip />
> That's weird, the compile was successfull if only I move this line into the
> try { } as following:
> 
> ----------------
>  public void convertFO2PDF(File fo, File pdf) throws IOException, 
>FOPException {
>         //fopFactory.setUserConfig(new 
>File("/opt/coolstack/fop/conf/fop.xconf"));
>         OutputStream out = null;
>         try {
>           fopFactory.setUserConfig(new 
>File("/opt/coolstack/fop/conf/fop.xconf"));

That's normal, and basic Java. FopFactory.setUserConfig() can throw a checked 
SAXException, which means you either have to add it to the 'throws' clause to 
the method signature, or you need to try-catch it explicitly.

Make it:
convertFO2PDF(...) throws IOException, SAXException {

Replacing FOPException with SAXException is sufficient, since a FOPException is 
itself a SAXException.

HTH!

Andreas


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]




      

Attachment: FopServlet.java
Description: Binary data

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to