Mervin Williams - 2005-10-29

Logged In: YES
user_id=699785

The "Resource Bundle Not Found" error is an indirect
exception that occurs because of either a malformed or
missing FO input to the Driver constructor. After meticulous
and painful research, I discovered that the error is a result of

a missing XMLMessages.properties file in the
org.apache.xerces.impl.msg package. To resolve, the author
should simply embed the XMLMessages (and likely the
XMLSchemaMessages.properties) in the .dll. In VS.NET,
simply change the Build Action for these files to Embedded
Resource.

As I mentioned, the direct cause of this problem is an
incomplete or missing FO file passed to the Driver method.
Here is a working example of passing the FO content via a
file into the Driver:

============================================

// Create PDF file from FOP and launch displaying it. Inputs
include the
// names of the FO document (ie. MyReport.fo) and the PDF
file (MyReport.pdf)
private void showPdfFile(string fullFoDoc, string pdfFile)
{
// Create parameters to pass into NFOP Driver
class
InputSource source = new InputSource(new
java.io.FileInputStream(fullFoDoc));
ByteArrayOutputStream output = new
ByteArrayOutputStream();

try
{
// Render PDF into a byte array
Driver driver = new Driver(source,
output);
driver.setRenderer
(Driver.RENDER_PDF);
driver.run();
output.close();
int sz = output.buf.Length;
byte[] pdf = new byte[sz];
for (int i = 0; i < sz; i++)
{ pdf[i] = (byte)output.buf[i]; }

// Generate the PDF file from the byte
array
BinaryWriter binWriter =
new BinaryWriter
(System.IO.File.Open(pdfFile, FileMode.Create));
binWriter.Write(pdf);
binWriter.Flush();
binWriter.Close();

// Finally, launch process to run the
PDF file, likely in Acrobat Reader
System.Diagnostics.Process p = new
System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo
pi =
new
System.Diagnostics.ProcessStartInfo();
pi.FileName = pdfFile;
p.StartInfo = pi;
p.Start();
}
catch (java.util.MissingResourceException mre)
{
MessageBox.Show("The following error
has occurred: " + mre.Message + "\r\n" +
"\r\n" +
"ClassName = "
+ mre.getClassName() + "\r\n" +
"Key = " +
mre.getKey() + "\r\n" +
"Localized
Message = " + mre.getLocalizedMessage() +
"\r\n",
"Error",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
catch (java.io.IOException ioe)
{
MessageBox.Show("The following error
has occurred: " + ioe.Message + "\r\n" +
"\r\n" +
"InnerException
= " + ioe.InnerException.Message + "\r\n" +
"Source = " +
ioe.InnerException.Source + "\r\n" +
"Localized
Message = " + ioe.getLocalizedMessage() + "\r\n",
"Error",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
catch (FOPException fope)
{
MessageBox.Show("The following error
has occurred: " + fope.Message + "\r\n" +
"\r\n" +
"InnerException
= " + fope.InnerException.Message + "\r\n" +
"Source = " +
fope.InnerException.Source + "\r\n" +
"Root Exception
= " + fope.getRootException().getMessage() +
"\r\n",
"Error",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
catch(Exception ex)
{
MessageBox.Show("The following error
has occurred: " + ex.Message + "\r\n" +
"\r\n" +
ex.StackTrace,
"Error",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
============================================
==============================

I hope this helps to save someone the grueling hours it took
me to resolve this issue.

Mervin Williams