Hi All,
I'm getting the "ORA-29534: referenced object could not be resolved" when trying to CREATE JAVA SOURCE.
please help....
I want to use following import for generate xml to pdf:
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
import org.apache.xmlgraphics.util.MimeConstants;
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> DROP JAVA SOURCE "OracleFop";
CREATE AND RESOLVE JAVA SOURCE NAMED "OracleFop" AS
package irelease;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.SQLException;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamSource;
import oracle.jdbc.OracleDriver;
import oracle.sql.BLOB;
import oracle.sql.CLOB;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
import org.apache.xmlgraphics.util.MimeConstants;
public class OracleFop {
private static Connection getConnection() throws SQLException {
Connection conn = (new OracleDriver()).defaultConnection();
return conn;
}
static public BLOB xmlToPdf(CLOB xml, CLOB xsl) throws Exception {
java.sql.Connection conn = getConnection();
// Step 1: Construct a FopFactory
// (reuse if you plan to render multiple documents!)
FopFactory fopFactory = FopFactory.newInstance();
// Step 2: Set up output stream.
// Note: Using BufferedOutputStream for performance reasons (helpful with FileOutputStreams).
BLOB pdf = null;
OutputStream out_fo = null;
OutputStream out_pdf = null;
try {
ByteArrayOutputStream out_fo_ba = new ByteArrayOutputStream();
out_fo = new BufferedOutputStream(out_fo_ba);
// 1. Instantiate a TransformerFactory.
javax.xml.transform.TransformerFactory tFactory =
javax.xml.transform.TransformerFactory.newInstance();
// 2. Use the TransformerFactory to process the stylesheet Source and generate a Transformer.
javax.xml.transform.Transformer transformer = tFactory.newTransformer
(new javax.xml.transform.stream.StreamSource(xsl.getCharacterStream()));
// 3. Use the Transformer to transform an XML Source and send the output to a Result object.
transformer.transform
(new javax.xml.transform.stream.StreamSource(xml.getCharacterStream()),
new javax.xml.transform.stream.StreamResult(out_fo));
out_fo.flush();
out_fo.close();
pdf = BLOB.createTemporary(conn, false, BLOB.DURATION_SESSION);
out_pdf = new BufferedOutputStream( pdf.setBinaryStream(0L) );
// 4. Construct fop with desired output format
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out_pdf);
// 5. Setup JAXP using identity transformer
transformer = tFactory.newTransformer(); // identity transformer
// 6. Setup input and output for XSLT transformation - Setup input stream
Source src = new StreamSource(new ByteArrayInputStream(out_fo_ba.toByteArray()));
// 7. Resulting SAX events (the generated FO) must be piped through to FOP
Result res = new SAXResult(fop.getDefaultHandler());
// 8. Start XSLT transformation and FOP processing
transformer.transform(src, res);
out_pdf.flush();
out_pdf.close();
}
catch( Exception e ) {
throw e;
}
finally {
//Clean-up
try { out_fo.close(); } catch(Exception e1) {}
try { out_pdf.close(); } catch(Exception e1) {}
}
return pdf;
}
}
Java dropped.
SQL> 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
101 /
Warning: Java created with compilation errors.
SQL> show err
Errors for JAVA SOURCE "OracleFop":
LINE/COL ERROR
-------- -----------------------------------------------------------------
0/0 ORA-29534: referenced object SCOTT.org/apache/fop/apps/Fop could not be resolved
SQL>