Loading Apache FOP configuration file in 2.6 throws a NullPointerException

Viewed 60

I upgrade Apache FOP from 2.3 to 2.7 and I now get a NullPointerException. I have isolated the issue to a change between version 2.5 and 2.6 within the function FopConfParser(File fopConfFile, ResourceResolver resourceResolver) in the file org.apache.fop.apps.FopConfParser.java, line 144:

2.5: this(new FileInputStream(fopConfFile), fopConfFile.toURI(), resourceResolver);

2.6: this(new FileInputStream(fopConfFile), fopConfFile.getParentFile().toURI(), resourceResolver);

The code below demonstrates the issue:

import java.io.File;
import java.io.IOException;

import org.apache.fop.apps.FopConfParser;
import org.xml.sax.SAXException;


public class Test
{
    private static final String FOP_CONFIGURATION_FILE = "fopConfiguration.xml";


    static
    {
        try
        {
            File configurationFile = new File( FOP_CONFIGURATION_FILE );
            FopConfParser fopConfParser = new FopConfParser( configurationFile );
        }
        catch( SAXException saxException ) { saxException.printStackTrace(); }
        catch( IOException ioException ) { ioException.printStackTrace(); }
        catch( Exception exception ) { exception.printStackTrace(); }
    }


    public static void main( String args[ ] ) { }
}

To test requires a few steps:

  1. Download FOP binary releases 2.5 and 2.6 and extract each archive.
  2. Save the test program above as Test.java and create sub-directories called 2.5 and 2.6.
  3. From the 2.5 extracted archive, copy conf/fop.xconf to the same directory as Test.java and copy build/fop.jar and lib/*.jar files to the 2.5 sub-directory. Similarly for 2.6.
  4. To compile: javac -cp "2.5/*" Test.java; to run: java -cp "2.5/*:." Test. Similarly for 2.6.

Any ideas on why the configuration file is no longer being located (perhaps to do with classpath) and any ideas please on how to resolve?

0 Answers
Related