I have produced a fop.dll from fop-1.0 with ikvm:
ikvmc -target:library -reference:IKVM.OpenJDK.Core.dll -recurse:{myPathToJars}\*.jar -version:1.0 -out:{myPathToJars}\fop.dll
If I use my fop.dll in a Windows Application, everything works perfect.
If I use it in a Class Library, I get the following error:
"Provider com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl not found" at javax.xml.transform.TransformerFactory.newInstance()
The code line is:
TransformerFactory factory = TransformerFactory.newInstance();Here is the code of method:
public static void xmlToPDF(String xmlPath, String xslPath, SortedList arguments, String destPdfPath) { java.io.File xmlfile = new java.io.File(xmlPath); java.io.File pdffile = new java.io.File(destPdfPath); try { // configure fopFactory as desired FopFactory fopFactory = FopFactory.newInstance(); FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); // configure foUserAgent as desired // Setup output OutputStream outputStream = new java.io.FileOutputStream(pdffile); outputStream = new java.io.BufferedOutputStream(outputStream); try { // Construct fop with desired output format Fop fop = fopFactory.newFop("application/pdf" /*MimeConstants.MIME_PDF*/, foUserAgent, outputStream); // Setup XSLT TransformerFactory factory = TransformerFactory.newInstance(); java.io.File xsltfile = new java.io.File(xslPath); Transformer transformer = factory.newTransformer(new StreamSource(xsltfile.getAbsoluteFile())); // Set the value of a in the stylesheet if (arguments != null) { IList keys = arguments.GetKeyList(); foreach (var key in keys) { Object value = arguments[key]; transformer.setParameter(key.ToString(), value); } } // Setup input for XSLT transformation Source src = new StreamSource(xmlfile); // Resulting SAX events (the generated FO) must be piped through to FOP Result res = new SAXResult(fop.getDefaultHandler()); // Start XSLT transformation and FOP processing transformer.transform(src, res); } catch (Exception e1) { System.Console.WriteLine(e1.Message); } finally { outputStream.close(); } } catch (Exception ex) { System.Console.WriteLine(ex.Message); } }
I used ikvm-0.46.0.1 to make my fop.dll (based on fop 1.0). I included the following jars:
avalon-framework-4.2.0.jar batik-all-1.7.jar commons-io-1.3.1.jar commons-logging-1.0.4.jar fop.jar serializer-2.7.0.jar xalan-2.7.0.jar xercesImpl-2.7.1.jar xml-apis-1.3.04.jar xml-apis-ext-1.3.04.jar xmlgraphics-commons-1.4.jar
Any idea why this error occurs? Why is the behaviour different between Windows Application and Class Library?
Addition 10/19/11:
I managed to get working the following:
- MyMainPrg (a Windows Forms Application)
- MyFopWrapper (a Class Library that calls fop.dll)
But for my case this is not the solution, because in my target project, I have the following structure:
- MainCmdLinePrg (a Console Application; calls DLL_1)
- DLL_1 (calls DLLsharedFop) {there are several DLLs that can call DLLsharedFop}
- DLLsharedFop (calls directly fop.dll; or - I don't care - might call MyFopWrapper)
Unfortunately this construct results in the error.
You can shorten to a pair (ACmdLinePrg,MyFopWrapper): already this does not work! But (MyMainPrg,MyFopWrapper) does...
com.sun.org.apache
- that should just beorg.apache
. No idea where it's getting the extra bit from, though. – Rup