Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 344216 - JCE NoSuchAlgorithmException
Summary: JCE NoSuchAlgorithmException
Status: RESOLVED NOT_ECLIPSE
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.7   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 3.7 M7   Edit
Assignee: JDT-Debug-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-28 18:26 EDT by cathy.ruby CLA
Modified: 2011-04-29 11:12 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description cathy.ruby CLA 2011-04-28 18:26:16 EDT
Build Identifier: 20100917-0705

The Java Cryptography Extension (JCE) is encountering runtime errors through Eclipse (Helios Release 1) on Mac. Using Mac OS X 10.6 64-bit, with Java 1.6 on the command line, I can load the "DH" algorithm from the JCE extension with no issues (see below).  However, from a plain vanilla project in Eclipse, this same code will compile correctly but will throw a NoSuchAlgorithmException at runtime. 

import java.security.*;
import javax.crypto.*;
class JCETest{
    public static void main(String[] arg){
        try {
            KeyPairGenerator myKpairGen=KeyPairGenerator.getInstance("DH");
            KeyAgreement myKeyAgree=KeyAgreement.getInstance("DH");
        } catch(java.security.NoSuchAlgorithmException e) {
            System.out.println(e); 
        }
    }
}

This problem largely precludes the use of this extension through Eclipse on Mac OSX (other common algorithms fail as well in the same way) - this example runs without error on Eclipse in Windows (Helios release 2) - is this a problem with Helios Release 1? Or with Mac OS X and its flavor of Java?

On Mac, I have tried the following without success:
(a) Under 'Installed JREs' in Eclipse preferences, altering the jce.jar location to its real location on disk (the automatically selected location from the Java frameworks was a linked file)
(b) Added jce.jar as a runtime classpath library

Reproducible: Always

Steps to Reproduce:
1. On Mac OS X, Helios Release 1, create a new Java project
2. Create a JCETest class with the above contents
3. Run the program - code compiles, but the NoSuchAlgorithmException is encountered. This same class compiles and runs without error from the command line
Comment 1 Ayushman Jain CLA 2011-04-29 00:31:39 EDT
(In reply to comment #0)
> This same class compiles and runs without error from the command line

Do you mean this compiles fine using javac or the eclipse compiler invoked from command line?
Can you also please try with Helios SR2 on Mac, since it seems to work fine on Windows for you.
Comment 2 cathy.ruby CLA 2011-04-29 10:52:28 EDT
This code compiles and runs from the command line (javac/java) but not through the Eclipse IDE.

Just tried this with 3.6.2 on Mac. This appears to be a problem with my workspace - this example in a fresh workspace runs correctly, but in my general development workspace does not, for both 3.6.1 and 3.6.2.  I've created a new workspace and reconstructed my development environment step-by-step and the example continues to work. I will continue to test this and will post back if it happens again.
Comment 3 Olivier Thomann CLA 2011-04-29 11:00:02 EDT
Did you try to refresh your installed JREs ?
Moving to JDT/Debug as this seems to be a runtime issue when running the program.
Comment 4 cathy.ruby CLA 2011-04-29 11:09:35 EDT
(In reply to comment #3)
> Did you try to refresh your installed JREs ?
> Moving to JDT/Debug as this seems to be a runtime issue when running the
> program.

Just went to Preferences > Installed JREs > Edit, clicked "Restore Default", and it worked! Is this what you meant by "refresh your installed JREs"? Anyway, great tip, thanks!
Comment 5 Olivier Thomann CLA 2011-04-29 11:12:54 EDT
(In reply to comment #4)
> Just went to Preferences > Installed JREs > Edit, clicked "Restore Default",
> and it worked! Is this what you meant by "refresh your installed JREs"? Anyway,
> great tip, thanks!
This is exactly what I meant. Glad it worked.
Closing as NOT_ECLIPSE.