Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Getting error - cannot find symbol for import and @

ora_1978Mar 19 2014 — edited Mar 21 2014

I am getting error like cannot find symbol for import and @ . How to resolve it ?

  1  create or replace and compile java source named "AddressTypeDbProcedure" as
  2  import javax.xml.bind.annotation.XmlAccessType;
  3  import javax.xml.bind.annotation.XmlAccessorType;
  4  import javax.xml.bind.annotation.XmlElement;
  5  import javax.xml.bind.annotation.XmlSeeAlso;
  6  import javax.xml.bind.annotation.XmlType;
  7  public class AddressType {
  8      @XmlElement(name = "StreetAddress")
  9      protected String streetAddress;
10      public String getStreetAddress() {
11          return streetAddress;
12      }
13      public void setStreetAddress(String value) {
14          this.streetAddress = value;
15      }
16* };
17  /

Warning: Java created with compilation errors.

SQL> show errors;
Errors for JAVA SOURCE "AddressTypeDbProcedure":

LINE/COL ERROR
-------- -----------------------------------------------------------------
0/0      AddressTypeDbProcedure:1: cannot find symbol
0/0      6 errors
0/0      location: package javax.xml.bind.annotation
0/0      import javax.xml.bind.annotation.XmlAccessType;
0/0      ^
0/0      AddressTypeDbProcedure:2: cannot find symbol
0/0      symbol  : class XmlAccessorType
0/0      location: package javax.xml.bind.annotation
0/0      import javax.xml.bind.annotation.XmlAccessorType;
0/0      ^
0/0      AddressTypeDbProcedure:3: cannot find symbol

LINE/COL ERROR
-------- -----------------------------------------------------------------
0/0      symbol  : class XmlElement
0/0      location: package javax.xml.bind.annotation
0/0      import javax.xml.bind.annotation.XmlElement;
0/0      ^
0/0      AddressTypeDbProcedure:4: cannot find symbol
0/0      symbol  : class XmlSeeAlso
0/0      location: package javax.xml.bind.annotation
0/0      import javax.xml.bind.annotation.XmlSeeAlso;
0/0      ^
0/0      AddressTypeDbProcedure:5: cannot find symbol
0/0      symbol  : class XmlType

LINE/COL ERROR
-------- -----------------------------------------------------------------
0/0      location: package javax.xml.bind.annotation
0/0      import javax.xml.bind.annotation.XmlType;
0/0      ^
0/0      AddressTypeDbProcedure:7: cannot find symbol
0/0      symbol  : class XmlElement
0/0      location: class AddressType
0/0      @XmlElement(name = "StreetAddress")
0/0      ^
0/0      symbol  : class XmlAccessType
SQL>

Vinodh

Comments

L-MachineGun Mar 19 2014

Perhaps setting this before your "CREATE ...." will work:

SET ESCCHAR @

Roman_OCP Mar 21 2014 — edited on Mar 21 2014

Hi All,

I'm getting the same problem, can't find the solution!

where does Oracle search for the import classes? I might miss out this...

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> CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "rom_Fop" RESOLVER ((* PUBLIC)) AS

  2  package rom_Fop;

  3

  4  import java.io.BufferedOutputStream;

  5  import java.io.ByteArrayInputStream;

  6  import java.io.ByteArrayOutputStream;

  7  import java.io.OutputStream;

  8  import java.io.PrintWriter;

  9  import java.io.StringWriter;

10  import java.sql.CallableStatement;

11  import java.sql.Connection;

12  import java.sql.SQLException;

13  import javax.xml.transform.Result;

14  import javax.xml.transform.Source;

15  import javax.xml.transform.sax.SAXResult;

16  import javax.xml.transform.stream.StreamSource;

17  import oracle.jdbc.OracleDriver;

18  import oracle.sql.BLOB;

19  import oracle.sql.CLOB;

20  import org.apache.fop.apps.Fop;

21  import org.apache.fop.apps.FopFactory;

22  import org.apache.xmlgraphics.util.MimeConstants;

23

24  public class OracleFop {

25

26      private static Connection getConnection() throws SQLException {

27          Connection conn = (new OracleDriver()).defaultConnection();

28

29          return conn;

30      }

31

32      static public BLOB xmlToPdf(CLOB xml, CLOB xsl) throws Exception {

33

34          java.sql.Connection conn = getConnection();

35

36          // Step 1: Construct a FopFactory

37          // (reuse if you plan to render multiple documents!)

38        FopFactory fopFactory = FopFactory.newInstance();

39

40          // Step 2: Set up output stream.

41          // Note: Using BufferedOutputStream for performance reasons (helpful with FileOutputStreams).

42          BLOB pdf = null;

43          OutputStream out_fo = null;

44          OutputStream out_pdf = null;

45

46         try {

47              ByteArrayOutputStream out_fo_ba = new ByteArrayOutputStream();

48              out_fo = new BufferedOutputStream(out_fo_ba);

49

50              // 1. Instantiate a TransformerFactory.

51              logInformation(conn, "1. Instantiate a TransformerFactory");

52              javax.xml.transform.TransformerFactory tFactory =

53                            javax.xml.transform.TransformerFactory.newInstanc

e();

54

55              // 2. Use the TransformerFactory to process the stylesheet Source and generate a Transformer.

56              logInformation(conn, "2. Use the TransformerFactory to processthe stylesheet Source and generate a Transformer.");

57              javax.xml.transform.Transformer transformer = tFactory.newTransformer

58                          (new javax.xml.transform.stream.StreamSource(xsl.getCharacterStream()));

59

60              // 3. Use the Transformer to transform an XML Source and send the output to a Result object.

61              logInformation(conn, "3. Use the Transformer to transform an XML Source and send the output to a Result object");

62              transformer.transform

63              (new javax.xml.transform.stream.StreamSource(xml.getCharacterStream()),

64               new javax.xml.transform.stream.StreamResult(out_fo));

65

66              out_fo.flush();

67              out_fo.close();

68

69              logInformation(conn, "create temporary blob for the PDF");

70              pdf = BLOB.createTemporary(conn, false, BLOB.DURATION_SESSION);

71

72              out_pdf = new BufferedOutputStream( pdf.setBinaryStream(0L) );

73

74              // 4. Construct fop with desired output format

75              logInformation(conn, "4. Construct fop with desired output format");

76              Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out_pdf);

77

78              // 5. Setup JAXP using identity transformer

79              logInformation(conn, "5. Setup JAXP using identity transformer");

80              transformer = tFactory.newTransformer(); // identity transformer

81

82              // 6. Setup input and output for XSLT transformation - Setup input stream

83              logInformation(conn, "6. Setup input and output for XSLT transformation - Setup input stream");

84              Source src = new StreamSource(new ByteArrayInputStream(out_fo_ba.toByteArray()));

85

86              // 7. Resulting SAX events (the generated FO) must be piped through to FOP

87              logInformation(conn, "7. Resulting SAX events (the generated FO) must be piped through to FOP");

88              Result res = new SAXResult(fop.getDefaultHandler());

89

90              // 8. Start XSLT transformation and FOP processing

91              logInformation(conn, "8. Start XSLT transformation and FOP processing");

92              transformer.transform(src, res);

93

94              out_pdf.flush();

95              out_pdf.close();

96

97          }

98          catch( Exception e ) {

99              logException(conn, e);

100              throw e;

101          }

102          finally {

103              //Clean-up

104              try { out_fo.close(); } catch(Exception e1) {}

105              try { out_pdf.close(); } catch(Exception e1) {}

106          }

107

108          return pdf;

109      }

110  }

111  /

Warning: Java created with compilation errors.

SQL> show err

Errors for JAVA SOURCE "rom_Fop":

LINE/COL ERROR

-------- -----------------------------------------------------------------

0/0      rom_Fop:19: cannot find symbol

0/0      symbol  : class Fop

0/0      location: package org.apache.fop.apps

0/0      import org.apache.fop.apps.Fop;

0/0      ^

0/0      rom_Fop:20: cannot find symbol

0/0      symbol  : class FopFactory

0/0      location: package org.apache.fop.apps

0/0      import org.apache.fop.apps.FopFactory;

0/0      ^

0/0      rom_Fop:21: cannot find symbol

0/0      symbol  : class MimeConstants

0/0      location: package org.apache.xmlgraphics.util

0/0      import org.apache.xmlgraphics.util.MimeConstants;

0/0      ^

0/0      rom_Fop:37: cannot find symbol

0/0      symbol  : class FopFactory

0/0      location: class rom_Fop.OracleFop

0/0      FopFactory fopFactory = FopFactory.newInstance();

0/0      ^

0/0      rom_Fop:37: cannot find symbol

0/0      symbol  : variable FopFactory

0/0      location: class rom_Fop.OracleFop

0/0      FopFactory fopFactory = FopFactory.newInstance();

0/0      ^

0/0      rom_Fop:50: cannot find symbol

0/0      symbol  : method         logInformation(java.sql.Connection,java.lang.String)

0/0      location: class rom_Fop.OracleFop

0/0      logInformation(conn, "1. Instantiate a TransformerFactory");

0/0      ^

0/0      rom_Fop:55: cannot find symbol

0/0      symbol  : method         logInformation(java.sql.Connection,java.lang.String)

0/0      location: class rom_Fop.OracleFop

0/0      logInformation(conn, "2. Use the TransformerFactory to process         the stylesheet Source and generate a Transformer.");

0/0      ^

0/0      rom_Fop:60: cannot find symbol

0/0      symbol  : method         logInformation(java.sql.Connection,java.lang.String)

0/0      location: class rom_Fop.OracleFop

0/0      logInformation(conn, "3. Use the Transformer to transform an XML         Source and send the output to a Result object");

0/0      ^

0/0      rom_Fop:68: cannot find symbol

0/0      symbol  : method         logInformation(java.sql.Connection,java.lang.String)

0/0      location: class rom_Fop.OracleFop

0/0      logInformation(conn, "create temporary blob for the PDF");

0/0      ^

0/0      rom_Fop:74: cannot find symbol

0/0      symbol  : method         logInformation(java.sql.Connection,java.lang.String)

0/0      location: class rom_Fop.OracleFop

0/0      logInformation(conn, "4. Construct fop with desired output         format");

0/0      ^

0/0      rom_Fop:75: cannot find symbol

0/0      symbol  : class Fop

0/0      location: class rom_Fop.OracleFop

0/0      Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out_pdf);

0/0      ^

0/0      rom_Fop:75: cannot find symbol

0/0      symbol  : variable MimeConstants

0/0      location: class rom_Fop.OracleFop

0/0      Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out_pdf);

0/0      ^

0/0      rom_Fop:78: cannot find symbol

0/0      symbol  : method         logInformation(java.sql.Connection,java.lang.String)

0/0      location: class rom_Fop.OracleFop

0/0      logInformation(conn, "5. Setup JAXP using identity transformer");

0/0      ^

0/0      rom_Fop:82: cannot find symbol

0/0      symbol  : method         logInformation(java.sql.Connection,java.lang.String)

0/0      location: class rom_Fop.OracleFop

0/0      logInformation(conn, "6. Setup input and output for XSLT         transformation - Setup input stream");

0/0      ^

0/0      rom_Fop:86: cannot find symbol

0/0      symbol  : method         logInformation(java.sql.Connection,java.lang.String)

0/0      location: class rom_Fop.OracleFop

0/0      logInformation(conn, "7. Resulting SAX events (the generated FO)         must be piped through to FOP");

0/0      ^

0/0      rom_Fop:90: cannot find symbol

0/0      symbol  : method         logInformation(java.sql.Connection,java.lang.String)

0/0      location: class rom_Fop.OracleFop

0/0      logInformation(conn, "8. Start XSLT transformation and FOP         processing");

0/0      ^

0/0      rom_Fop:98: cannot find symbol

0/0      symbol  : method         logException(java.sql.Connection,java.lang.Exception)

0/0      location: class rom_Fop.OracleFop

0/0      logException(conn, e);

0/0      ^

0/0      17 errors

SQL>

sami Mar 21 2014

Hi Roman,

import org.apache.fop.apps.Fop;

21  import org.apache.fop.apps.FopFactory;

22  import org.apache.xmlgraphics.util.MimeConstants;

I hope your missing this classes.. better import classes with corresponding jar files by using

$loadjava -user username/password-resolve -synonym path of jar

Thanks

Sami

Roman_OCP Mar 21 2014

Hi Sami,

Thanks for your time and response, I have load the jar as you suggest but getting same error!

following command run without error:

[oracle11@imp ~]$ loadjava -user scott/tiger@orcl11 /home/oracle11/Downloads/fop-1.1/lib/xmlgraphics-commons-1.5.jar

[oracle11@imp ~]$ loadjava -user scott/tiger@orcl11 /home/oracle11/Downloads/fop.jar

and getting the error at the time of CREATE  JAVA SOURCE

SQL> /

Warning: Java created with compilation errors.

SQL> show err

Errors for JAVA SOURCE "rom_Fop":

LINE/COL ERROR

-------- -----------------------------------------------------------------

0/0      rom_Fop:19: cannot find symbol

0/0      symbol  : class Fop

0/0      location: package org.apache.fop.apps

0/0      import org.apache.fop.apps.Fop;

0/0      ^

0/0      rom_Fop:20: cannot find symbol

0/0      symbol  : class FopFactory

0/0      location: package org.apache.fop.apps

0/0      import org.apache.fop.apps.FopFactory;

0/0      ^

0/0      rom_Fop:21: cannot find symbol

1 - 4
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Apr 18 2014
Added on Mar 19 2014
4 comments
2,897 views