Has anyone succeded in embedding FOP in Oracle 9iAS?

I am having real trouble with the following code in a servlet run in OC4J:


*************

TransformerFactory transformerfactory = TransformerFactory.newInstance();

//Check if the factory supports SAX
if (transformerfactory.getFeature(SAXSource.FEATURE)) {

  SAXTransformerFactory stfactory = ((SAXTransformerFactory)
transformerfactory);

  StreamSource ssxsl = new StreamSource(fFichXSL);   //fFichXSL: file with the
XSL template
  Transformer transformer = stfactory.newTransformer(ssxsl);
  StreamSource ssxml = new StreamSource(fFichXML);  //fFichXML: file with data
in XML

  Driver fopDriver = new Driver();

  //I do not want FOP logger
  Logger objlog = new ConsoleLogger(ConsoleLogger.LEVEL_DISABLED);
  MessageHandler.setScreenLogger(objlog);
  fopDriver.setLogger(objlog);

  fopDriver.setRenderer(Driver.RENDER_PDF);

  //Resulting PDF in a buffer
  ByteArrayOutputStream baosout = new ByteArrayOutputStream();
  fopDriver.setOutputStream(baosout);

  ContentHandler ch = fopDriver.getContentHandler();

  //The result controlled by FOP
  SAXResult sxres = new SAXResult(ch);

  //Perform the XSLT transformation (here is the exception)
  transformer.transform(ssxml,sxres);

}

*********

When running that code, the following Exception occurs:

Servlet error: java.lang.NullPointerException
     at oracle.xml.jaxp.JXTransformer.reportXSLException(JXTransformer.java:762)
     at oracle.xml.jaxp.JXTransformer.transform(JXTransformer.java:335)
     at generador.vObtenerContrato(generador.java:1181)
     at generador.doPost(generador.java:480)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
     at
com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)

     at oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java:283)
     at
com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:560)

     at
com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)

     at
com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)

     at
com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:148)
     at
com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:72)
     at
EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)

     at java.lang.Thread.run(Thread.java:479)


************


However, if I do not use the FOP Driver but a simple File, it works also with
Oracle:

PrintWriter pw = new PrintWriter(new FileOutputStream("result.fo"));
//Driver driver = new Driver();
//driver.setOutputStream(getResultOutputStream());
//driver.setRenderer(Driver.RENDER_PDF);
Transformer transformer=
(TransformerFactory.newInstance()).newTransformer(getXSLSource());
transformer.transform(getXMLSource(), new
//SAXResult(driver.getContentHandler()));
StreamResult(pw));


so it has to do with the interaction between Oracle XML API and FOP.






I am afraid that the problem is the XSLT and XMLParser Oracle implementations,
but I am not either able to replace them with Xalan and Xerces:

1.- Of course:
System.setProperty("javax.xml.transform.TransformerFactory","org.apache.xalan.processor.TransformerFactoryImpl");

System.setProperty("javax.xml.parsers.SAXParserFactory","org.apache.xerces.jaxp.SAXParserFactoryImpl");

doesn't work within a servlet


2.- Adding a META-INF/services/javax.xml.transform.TransformerFactory (with the
text "org.apache.xalan.processor.TransformerFactoryImpl") file in the .WAR
file doesn´t work


3.- I think that Oracle 9iAS doen´t use a  "lib/jaxp.properties" file, so it is
not possible to use it.



Any ideas?

Regards,

Miguel Peña.





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to