Hello Specialists,
I've following problem (the same as described in: [; ...)
A java mapping for rendering PDF based on apache's FOP throws an exception:
...
javax.xml.transform.TransformerException: java.lang.ClassCastException:
class com.sap.aii.ib.server.mapping.execution.jaxpfactories.MappingTransformerFactory:sap.com/com.sap.xi.repository com.sap.engine.boot.loader.ResourceMultiParentClassLoader ... alive
incompatible with class javax.xml.transform.sax.SAXTransformerFactory:null at
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:670) at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:300) at de.cceag.pi.mapping.fo.java.FOPHandler.transformPDF(FOPHandler.java:85)
...
For developing I use NWDS 7.1 and JDK 1.5.0_17 ... I also tried JDK 1.5.0_22. Finally, I tried using the rt.jar from SAPs jvm (.../sapjvm_5/jre/lib).
Here a code snippet:
... import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import javax.xml.transform.Result; import javax.xml.transform.Source; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.sax.SAXResult; import javax.xml.transform.stream.StreamSource; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.Fop; import org.apache.fop.apps.FopFactory; import org.apache.fop.apps.MimeConstants; ... public ByteArrayOutputStream transformPDF(ByteArrayInputStream in, ByteArrayOutputStream out) throws FOPException, TransformerException { // Step 2: Set up output stream. // Note: Using BufferedOutputStream for performance reasons (helpful with FileOutputStreams). try { // Step 3: Construct fop with desired output format Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, this.foUserAgent, out); // Step 4: Setup JAXP using identity transformer TransformerFactory factory = TransformerFactory.newInstance(); // TransformerFactory factory = TransformerFactoryImpl.newInstance(); // SAXTransformerFactory factory = (SAXTransformerFactory) SAXTransformerFactory.newInstance(); // identity transformer Transformer transformer = factory.newTransformer(); // Step 5: Setup input and output for XSLT transformation // Setup input stream Source src = new StreamSource(in); // Resulting SAX events (the generated FO) must be piped through to FOP Result res = new SAXResult(fop.getDefaultHandler()); // Step 6: Start XSLT transformation and FOP processing transformer.transform(src, res); ...
We use PI 7.11 SP6. The 'Use SAP XML Toolkit' option in operation mapping is deactivated.
Any ideas?
Thanks and Regards
André