java.security.NoSuchProviderException: no such provider: SunMSCAPI - java

I have several programs that use SunMSCAPI to read web pages that require an SSL certificate. My code works under Windows XP (32 bit) but does not work under my fresh installation of Windows 7 (64 bit). Here is the piece of code:
System.setProperty("javax.net.ssl.keyStoreProvider", "SunMSCAPI");
System.setProperty("javax.net.ssl.keyStoreType", "WINDOWS-MY");
System.setProperty("javax.net.ssl.trustStoreProvider", "SunMSCAPI");
System.setProperty("javax.net.ssl.trustStoreType", "WINDOWS-ROOT");
System.setProperty("proxyHost", "proxy");
System.setProperty("proxyPort", "8080");
URL url = new URL(TEST_URL);
try {
HttpsURLConnection httpsCon = (HttpsURLConnection) url.openConnection();....
And here is the stack trace:
Caused by: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl)
at java.security.Provider$Service.newInstance(Unknown Source)
at sun.security.jca.GetInstance.getInstance(Unknown Source)
at sun.security.jca.GetInstance.getInstance(Unknown Source)
at javax.net.ssl.SSLContext.getInstance(Unknown Source)
at javax.net.ssl.SSLContext.getDefault(Unknown Source)
at javax.net.ssl.SSLSocketFactory.getDefault(Unknown Source)
at javax.net.ssl.HttpsURLConnection.getDefaultSSLSocketFactory(Unknown Source)
at javax.net.ssl.HttpsURLConnection.<init>(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.<init>(Unknown Source)
at sun.net.www.protocol.https.Handler.openConnection(Unknown Source)
at sun.net.www.protocol.https.Handler.openConnection(Unknown Source)
at java.net.URL.openConnection(Unknown Source)
at GetData2.SetVallues(GetData2.java:56) *// HttpsURLConnection httpsCon = (HttpsURLConnection) url.openConnection();*
... 2 more
Caused by: java.security.NoSuchProviderException: no such provider: SunMSCAPI
at sun.security.jca.GetInstance.getService(Unknown Source)
at sun.security.jca.GetInstance.getInstance(Unknown Source)
at java.security.Security.getImpl(Unknown Source)
at java.security.KeyStore.getInstance(Unknown Source)
at com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl.getDefaultKeyManager(Unknown Source)
at com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl.<init>(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
... 15 more
I've tried also following example http://muhammadhamed.blogspot.com/2010/04/accessing-ms-certificate-stores-in-java.html but again received this NoSuchProviderException. My guess is that there is some configuration error but I'm not sure what it is.
Here is my JVM information:
java version "1.6.0_23"
Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
Java HotSpot(TM) 64-Bit Server VM (build 19.0-b09, mixed mode)
I hope somebody will be able to help me :-)
Best regards.

The J2SE Security page only says that the MS CryptoAPI (which SunMSCAPI uses) is only available under Java 6 on 32-bit Windows.
Luckily, you can still install the 32-bit JVM on Win64.

Related

My application can not be launched on java 8u231

I am trying to launch my application on java 8u231, but it failed with error "A JNI error has occurred, please check your installation and try again". However, the same application can be launched on java 8u102.
java -version
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)
PATH=%PATH%;.\lib
java -D... -Xmx512m MyFullApplication
11/18-16:23:49.00356 [main#1] jdk.internal.event.EventHelper.logX509CertificateEvent
FINE: X509Certificate: Alg:{0}, Serial:{1}, Subject:{2}, Issuer:{3}, Key type:{4}, Length:{5}, Cert Id:{6}, Valid from:{7}, Valid until:{8}
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NullPointerException
at java.util.jar.JarVerifier.processEntry(Unknown Source)
at java.util.jar.JarVerifier.update(Unknown Source)
at java.util.jar.JarFile.initializeVerifier(Unknown Source)
at java.util.jar.JarFile.ensureInitialization(Unknown Source)
at java.util.jar.JavaUtilJarAccessImpl.ensureInitialization(Unknown Source)
at sun.misc.URLClassPath$JarLoader$2.getManifest(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
I am launching my application from command line but not from the Eclipse. The jar file is pre-built and I can launch the jar with java 8u102 and java 8u221, but it can not be launched by java 8u231, so I guess is there bug of JRE itself which introduced this issue?

cant open jar files using double click

I already tried jarfix and jar runner and the cmd command("javaw.exe -jar .jar" and it was written that [unable to access .jar])
here is my java version:
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
tried:
1.java -jar "C:\Path to File\myJar.jar"
result:fail
Stacktrace:
Error: A JNI error has occurred, please check your installation and try again Exception in thread "main" java.lang.NoClassDefFoundError: joptsimple/OptionException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source) Caused by: java.lang.ClassNotFoundException: joptsimple.OptionException
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more
If there are spaces in the path this can cause such a failure. Even if it is the current directory.
So write something like this:
java -jar "C:\Path to File\myJar.jar"
Otherwise it might be a permissions issue. Check the file permissions.

How to resolve dll UnsatisfiedLinkError when using JNA 4.2.0 with Java 6 on Windows 7.1?

I'm using version 4.2.0 of the JNA libraries from here: https://github.com/java-native-access/jna.
My application works absolutely fine on Java 7 & 8 32-bit on a 64-bit Windows 7.1 machine.
When I try to load it using Java 6 32-bit, I get this error:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.UnsatisfiedLinkError: C:\Users\user\AppData\Local\Temp\jna-205523658\jna1343790277438028829.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:851)
at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:826)
at com.sun.jna.Native.<clinit>(Native.java:140)
at com.sun.jna.Pointer.<clinit>(Pointer.java:41)
at com.sun.jna.platform.win32.WinReg$HKEY.<init>(WinReg.java:32)
at com.sun.jna.platform.win32.WinReg.<clinit>(WinReg.java:61)
Is this an incompatibility issue between 32-bit Java 6 on a 64-bit OS? Is there anything I can do about it?
My problem is that I need to deploy my app to a wide user base all with different permutations of Java 32-bit on different Windows operating systems.

not able to run java application from command line

I am trying to run java desktop application using command line.In this application I am using the serial port to communicate ans send and receive request and response.So i am using the RXTXserail.dll file and RXTXcomm.jar file.I am creating the application using net beans 7.1 version under the windows 7 OS.
It was running from net beans plate form but when i try to run the application jar file that time i am getting this below error
"C:\configurationtool\ModbusZigBee\dist>java -jar ModbusZigBee.jar
java.lang.UnsatisfiedLinkError: C:\Program Files\Java\jre6\bin\rxtxSerial.dll: C
an't load IA 32-bit .dll on a AMD 64-bit platform thrown while loading gnu.io.RX
TXCommDriver
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: C:\Progra
m Files\Java\jre6\bin\rxtxSerial.dll: Can't load IA 32-bit .dll on a AMD 64-bit
platformSubstance Raven Graphite failed to initialize
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at gnu.io.CommPortIdentifier.<clinit>(CommPortIdentifier.java:123)
at modbuszigbee.SerialInterface.<init>(SerialInterface.java:58)
at modbuszigbee.ModbusZigBeeView.<init>(ModbusZigBeeView.java:111)
at modbuszigbee.ModbusZigBeeApp.startup(ModbusZigBeeApp.java:22)
at org.jdesktop.application.Application$1.run(Application.java:171)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$400(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown
Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)"
I am using 32 bit java 6 in my system. and rxtxserial.dll also 32 bit.i tried with 64 bit of rxtxserial.dll.But it did not work.
Please help.Thanks in advance.

InitialLdapContext fails with Java 6 and Java 7

I am working with GSSAPI successfully with JAVA 5. With JAVA 6 and 7 the InitialLdapContext call fails with the following stacktrace:
>>>KRBError:
sTime is Fri Jun 14 13:40:01 CEST 2013 1371210001000
suSec is 948732
error code is 7
error Message is Server not found in Kerberos database
realm is DE.XXX.NET
sname is ldap/yyy.de.xxx.net
msgType is 30
KrbException: Server not found in Kerberos database (7)
at sun.security.krb5.KrbTgsRep.<init>(Unknown Source)
at sun.security.krb5.KrbTgsReq.getReply(Unknown Source)
at sun.security.krb5.KrbTgsReq.sendAndGetCreds(Unknown Source)
at sun.security.krb5.internal.CredentialsUtil.serviceCreds(Unknown Source)
at sun.security.krb5.internal.CredentialsUtil.acquireServiceCreds(Unknown Source)
at sun.security.krb5.Credentials.acquireServiceCreds(Unknown Source)
at sun.security.jgss.krb5.Krb5Context.initSecContext(Unknown Source)
at sun.security.jgss.GSSContextImpl.initSecContext(Unknown Source)
at sun.security.jgss.GSSContextImpl.initSecContext(Unknown Source)
at com.sun.security.sasl.gsskerb.GssKrb5Client.evaluateChallenge(Unknown Source)
at com.sun.jndi.ldap.sasl.LdapSasl.saslBind(Unknown Source)
at com.sun.jndi.ldap.LdapClient.authenticate(Unknown Source)
at com.sun.jndi.ldap.LdapCtx.connect(Unknown Source)
at com.sun.jndi.ldap.LdapCtx.<init>(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(Unknown Source)
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.ldap.InitialLdapContext.<init>(Unknown Source)
at kerberos.UserRoles2.getUserRoles(UserRoles2.java:27)
at kerberos.Server$2.run(Server.java:240)
at kerberos.Server$2.run(Server.java:1)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Unknown Source)
at kerberos.Server.getRoles(Server.java:233)
at kerberos.Server.main(Server.java:95)
Caused by: KrbException: Identifier doesn't match expected value (906)
at sun.security.krb5.internal.KDCRep.init(Unknown Source)
at sun.security.krb5.internal.TGSRep.init(Unknown Source)
at sun.security.krb5.internal.TGSRep.<init>(Unknown Source)
... 29 more
Problem searching directory: javax.naming.AuthenticationException: GSSAPI [Root exception is javax.security.sasl.SaslException: GSS initiate failed [Caused by GSSException: No valid credentials provided (Mechanism level: Server not found in Kerberos database (7))]]
Does anybody has an idea what ist going wrong in Java 6 or 7?
The ktab file is created with the ktab tool of a jre 7.
"c:\Program Files\Java\jre7\bin\ktab.exe" -a user#DOMAIN.DE password -k my.keytab -n 0
"c:\Program Files\Java\jre7\bin\ktab.exe" -a Service/host#DOMAIN.DE password -k my.keytab -n 0
Windows server 2008 Active directory
Please remember: If I am using Java 5 the InitialLdapContext call is working as expected.
Thanks in advance
Michael
Problem is solved.
I have used an alias dns name for the ldap_url property. In Java 1.5 the alias dns name was resolved to the real dns name. In Java 1.6 and 1.7 the resolving does not happen.
The change to a real dns name solved the problem.

Categories

Resources