5 Replies Latest reply on Mar 27, 2013 3:31 PM by Gary Graham-Oracle

    SQL Developer load Java error

      Hello, I'm trying to load Java code to my Oracle SQL developer. On Load java, I choose Java source from my hdd (from NetBeans destination folder) and I get the below error. Any help?

      error code:
          Error in Source Code  
          &Exception in Stack Trace 1 of 1  
          java.sql.SQLSyntaxErrorException: ORA-24344: success with compilation error  
          ORA-06512: at line 1  
              at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:447)  
              at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)  
              at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:879)  
      here is the code. It works well in NetBeans and I'm trying to load it in SQL Developer in .java file
      package c2_01_signhelloworld;
      import java.io.FileInputStream;
      import java.io.FileOutputStream;
      import java.io.IOException;
      import java.security.GeneralSecurityException;
      import java.security.KeyStore;
      import java.security.PrivateKey;
      import java.security.Security;
      import java.security.cert.Certificate;
      import org.bouncycastle.jce.provider.BouncyCastleProvider;
      import com.itextpdf.text.DocumentException;
      import com.itextpdf.text.Rectangle;
      import com.itextpdf.text.pdf.PdfReader;
      import com.itextpdf.text.pdf.PdfSignatureAppearance;
      import com.itextpdf.text.pdf.PdfStamper;
      import com.itextpdf.text.pdf.security.BouncyCastleDigest;
      import com.itextpdf.text.pdf.security.DigestAlgorithms;
      import com.itextpdf.text.pdf.security.ExternalDigest;
      import com.itextpdf.text.pdf.security.ExternalSignature;
      import com.itextpdf.text.pdf.security.MakeSignature;
      import com.itextpdf.text.pdf.security.MakeSignature.CryptoStandard;
      import com.itextpdf.text.pdf.security.PrivateKeySignature;
      public class C2_01_SignHelloWorld {
          public static final String KEYSTORE = "C:/Users/myFile/Documents/itext/2/ks";
          public static final char[] PASSWORD = "password".toCharArray();
          public static final String SRC = "C:/Users/myfile/Documents/itext/2/unsigned1.pdf";
          public static final String DEST = "C:/Users/myfile/Documents/itext/2/unsigned1_signed.pdf";
          public void sign(String src, String dest,
                  Certificate[] chain,
                  PrivateKey pk, String digestAlgorithm, String provider,
                  CryptoStandard subfilter,
                  String reason, String location)
                          throws GeneralSecurityException, IOException, DocumentException {
              // Creating the reader and the stamper
              PdfReader reader = new PdfReader(src);
              FileOutputStream os = new FileOutputStream(dest);
              PdfStamper stamper = PdfStamper.createSignature(reader, os, '\0');
              // Creating the appearance
              PdfSignatureAppearance appearance = stamper.getSignatureAppearance();
              appearance.setVisibleSignature(new Rectangle(36, 748, 144, 780), 1, "sig");
              // Creating the signature
              ExternalDigest digest = new BouncyCastleDigest();
              ExternalSignature signature = new PrivateKeySignature(pk, digestAlgorithm, provider);
              MakeSignature.signDetached(appearance, digest, signature, chain, null, null, null, 0, subfilter);
          public static void main(String[] args) throws GeneralSecurityException, IOException, DocumentException {
              BouncyCastleProvider provider = new BouncyCastleProvider();
              KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
              ks.load(new FileInputStream(KEYSTORE), PASSWORD);
              String alias = (String)ks.aliases().nextElement();
              PrivateKey pk = (PrivateKey) ks.getKey(alias, PASSWORD);
              Certificate[] chain = ks.getCertificateChain(alias);
              C2_01_SignHelloWorld app = new C2_01_SignHelloWorld();
              app.sign(SRC, String.format(DEST, 1), chain, pk, DigestAlgorithms.SHA256, provider.getName(), CryptoStandard.CMS, "Test 1", "Ghent");
              app.sign(SRC, String.format(DEST, 2), chain, pk, DigestAlgorithms.SHA512, provider.getName(), CryptoStandard.CMS, "Test 2", "Ghent");
              app.sign(SRC, String.format(DEST, 3), chain, pk, DigestAlgorithms.SHA256, provider.getName(), CryptoStandard.CADES, "Test 3", "Ghent");
              app.sign(SRC, String.format(DEST, 4), chain, pk, DigestAlgorithms.RIPEMD160, provider.getName(), CryptoStandard.CADES, "Test 4", "Ghent");
        • 1. Re: SQL Developer load Java error
          Gary Graham-Oracle

          This could be one of those cases where using Java 7 versus Java 6 makes a difference, or perhaps there is some conflict with the JDBC driver version. So, a few things to try...

          1. Make sure your installation's SetJavaHome line in ...\sqldeveloper\sqldeveloper\bin\sqldeveloper.conf points to a Java 6 JDK.
          2. If (1) does not work, also uncheck the Use OCI/Thick driver box in Tools -> Preferences -> Database -> Advanced.
          3. If (1) and (2) do not work, also copy the ojdbc6.jar from any Oracle client you might have installed to your installation's ...\sqldeveloper\jdbc\lib directory

          I would think doing just (1) should be sufficient. If on Mac OS, use sqldeveloper-Darwin.conf instead.

          Hope this helps and please post back here and let us know, one way or the other,
          SQL Developer Team
          1 person found this helpful
          • 2. Re: SQL Developer load Java error
            Thank you for your reply. When I open in Notepad++ ...\sqldeveloper\sqldeveloper\bin\sqldeveloper.conf it points to : SetJavaHome ../../jdk if I change this line into C:/Program Files/Java/jdk1.6.0_41 i get error message : Please check if this file is opened in another program.. SQL Developer is not running and it's closed

            UPDATE: Solved this one. Permission for this file was not set..

            Edited by: Branko1986 on 2013.03.27 08:46
            • 3. Re: SQL Developer load Java error
              I tried all of this things, but none of them unfortunately didn't work.. So I created file directory on my server and loaded file through Oracle Directory Resource and in Selected file pointed to file on directory... It works well. I had to change only lines that point on files and put in them path to the directory on server:
              public static final String KEYSTORE = "C:/..file on server../2/ks";
                  public static final char[] PASSWORD = "password".toCharArray();
                  public static final String SRC = "C:/..file on server../unsigned1.pdf";
                  public static final String DEST = "C:/..file on server..unsigned1_signed.pdf"; 
              • 4. Re: SQL Developer load Java error
                I created file directory on my server and loaded file through Oracle Directory Resource and in Selected file pointed to file on directory... It works well
                • 5. Re: SQL Developer load Java error
                  Gary Graham-Oracle
                  Thanks for the feedback, and glad to know you got it working by loading via Oracle Directory Resource. I actually did see the same error when using Java 7, but that was not against a stable version of the product.

                  Thanks again,
                  1 person found this helpful