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:
- Download FOP binary releases
2.5and2.6and extract each archive. - Save the test program above as
Test.javaand create sub-directories called2.5and2.6. - From the
2.5extracted archive, copyconf/fop.xconfto the same directory asTest.javaand copybuild/fop.jarandlib/*.jarfiles to the2.5sub-directory. Similarly for2.6. - To compile:
javac -cp "2.5/*" Test.java; to run:java -cp "2.5/*:." Test. Similarly for2.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?