Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 89935 - Cipher.getInstance fails if using JRE without "Use default system libraries"
Summary: Cipher.getInstance fails if using JRE without "Use default system libraries"
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.0.1   Edit
Hardware: All All
: P2 major (vote)
Target Milestone: 3.1 RC1   Edit
Assignee: Luc Bourlier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 46510 95898 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-04-01 06:07 EST by Michael Petig CLA
Modified: 2005-07-06 16:18 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 Michael Petig CLA 2005-04-01 06:07:05 EST
When running a java application from Eclipse with Debug or Run, then code
requesting a Cipher object through Cipher.getInstance will fail. This only
happens if the JRE used is not configured (Window, Preferences, Java, Installed
JREs, ${jre}, Edit) to "Use default system libraries ".

Example code to produce the error:
---
public static void main(String[] args) {
  Cipher cp;
  try {
    cp=Cipher.getInstance("DES/ECB/NoPadding", "SunJCE");
    cp=Cipher.getInstance("DES/ECB/NoPadding");
    System.out.println("JCE OK");
  } catch (NoSuchAlgorithmException e) {
    e.printStackTrace();
  } catch (NoSuchProviderException e) {
    e.printStackTrace();
  } catch (NoSuchPaddingException e) {
    e.printStackTrace();
  }
}
---
With "Use default system libraries" it works without problems.
With default configuration for JRE and "Use default system libraries" switched off,
it produces following stack dump:
---
Exception in thread "main" java.lang.SecurityException: JCE cannot authenticate
the provider SunJCE
	at javax.crypto.Cipher.getInstance(DashoA12275)
	at javax.crypto.Cipher.getInstance(DashoA12275)
	at TestCaseJCE.main(TestCaseJCE.java:22)
Caused by: java.util.jar.JarException: Class is on the bootclasspath
	at javax.crypto.SunJCE_d.a(DashoA12275)
	at javax.crypto.SunJCE_b.b(DashoA12275)
	at javax.crypto.SunJCE_b.a(DashoA12275)
	... 3 more
---
As far as I have discovered this is caused by JRE default setting, placing all
jar files from lib/ext directory into bootclasspath when "Use default system
libraries" is switched off. This includes the SUN JCE provider
"sunjce_provider.jar". Obviously the verification of the JCE provider fails if
it is located in bootclasspath. The problem can be easily solved by removing
sunjce_provider.jar from list of JRE jar files. Then again the above code runs
without problems.
In my opinion the default settings when importing a JRE into Eclipse should be
changed not to include sunjce_provider.jar.
One may argue that switching off "Use default system libraries" is typically not
the case, but if source code is attached to one of the JRE jar files (including
the lib/ext files), then this is done automatically by Eclipse.

PS: I have discovered the problem running Windows XP on PC platform. Anyway I
expect the problem to be platform and OS independent. I may have assigned the
problem to the wrong component, please correct this if there is a better
component fitting this problem.
Comment 1 Darin Wright CLA 2005-04-01 11:33:38 EST
Verified that changing a source attachment on a system lib does cause the 
bootpath to be specified explcitly on the launch commad line. Chaing a source 
attachment or javadoc location should not require the boot path to be 
specified by the launcher - only a change in libs or ordering of them.
Comment 2 Darin Wright CLA 2005-05-16 15:57:49 EDT
Fixed in JRERuntimeClasspathEntryResolver and 
AbstractJavaLaunchConfigurationDelegate. When comparing the default libaries 
to the user specified libraries, the comparison only considers the archive 
locations (ignores source attachment, javadoc, etc). At runtime, only the 
binaries matter.
Comment 3 Darin Wright CLA 2005-05-16 15:58:06 EDT
Please verify, Luc.
Comment 4 Ralf Hauser CLA 2005-05-19 12:21:36 EDT
Very related bug Bug 95898
Comment 5 Kevin Barnes CLA 2005-05-19 12:45:49 EDT
*** Bug 95898 has been marked as a duplicate of this bug. ***
Comment 6 Luc Bourlier CLA 2005-05-23 14:30:50 EDT
Verified.
Comment 7 Alexander Wessel CLA 2005-06-30 08:58:49 EDT
Hi guys,  
  
can someone explain/verify that this bug is fixed in Eclipse 3.1 final with  
Sun JDK 1.5.0_04? Could there have been a regression?  
  
I still get the error when trying to establish a connection to an SSL Endpoint  
via Apache Axis Client code from my JUnit Test cases.  
  
When I activate "Use default system libraries" in the JRE properties, it  
works, when I deactivate it, and add JDK's src.zip, I get the error.  
  
When I run the JUnit Testcase from the command line against the same JDK (with  
the same set of options) everything works fine... 
 
Scratching my head, waiting for enlightenment, 
Flexx 
Comment 8 Luc Bourlier CLA 2005-06-30 13:56:11 EDT
I cannot reproduce the problem with the test case from this bug report.
It is possible there's still a problem when launching a JUnit test case (it's
not the same code).
Please file an new bug report, with a simple test case if possible.
Comment 9 Darin Wright CLA 2005-07-06 16:18:50 EDT
*** Bug 46510 has been marked as a duplicate of this bug. ***