SunTlsRsaPremasterSecret KeyGenerator not available - java

I encountered an error when my application tries to load a RSA Algorithm provider class from JAVA. The exception stack is as follow:
javax.jms.JMSException: RSA premaster secret error
at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:49)
at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1255)
at org.apache.activemq.ActiveMQConnection.ensureConnectionInfoSent(ActiveMQConnection.java:1350)
at org.apache.activemq.ActiveMQConnection.setClientID(ActiveMQConnection.java:388)
at com.trendmicro.tmsm.TMSMAgent.open(TMSMAgent.java:63)
Caused by: javax.net.ssl.SSLKeyException: RSA premaster secret error
at com.sun.net.ssl.internal.ssl.RSAClientKeyExchange.<init>(RSAClientKeyExchange.java:97)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverHelloDone(ClientHandshaker.java:634)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:226)
at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:516)
at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:454)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:884)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1112)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:623)
at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:59)
at org.apache.activemq.transport.tcp.TcpBufferedOutputStream.flush(TcpBufferedOutputStream.java:115)
at java.io.DataOutputStream.flush(DataOutputStream.java:106)
at org.apache.activemq.transport.tcp.TcpTransport.oneway(TcpTransport.java:167)
at org.apache.activemq.transport.InactivityMonitor.oneway(InactivityMonitor.java:237)
at org.apache.activemq.transport.WireFormatNegotiator.sendWireFormat(WireFormatNegotiator.java:168)
at org.apache.activemq.transport.WireFormatNegotiator.sendWireFormat(WireFormatNegotiator.java:84)
at org.apache.activemq.transport.WireFormatNegotiator.start(WireFormatNegotiator.java:74)
at org.apache.activemq.transport.failover.FailoverTransport.doReconnect(FailoverTransport.java:715)
at org.apache.activemq.transport.failover.FailoverTransport$2.iterate(FailoverTransport.java:115)
at org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:122)
at org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:43)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:637)
Caused by: java.security.NoSuchAlgorithmException: SunTlsRsaPremasterSecret KeyGenerator not available
at javax.crypto.KeyGenerator.<init>(DashoA13*..)
at javax.crypto.KeyGenerator.getInstance(DashoA13*..)
at com.sun.net.ssl.internal.ssl.JsseJce.getKeyGenerator(JsseJce.java:223)
at com.sun.net.ssl.internal.ssl.RSAClientKeyExchange.<init>(RSAClientKeyExchange.java:89)
... 22 more
I've googled the error message and most of posts says it's because JVM cannot find sunjce_provider.jar. However, I can find the file in /Library/Java/Home/lib/ext folder.
The platform is Mac OS X 10.6 and Java version is 1.6.0_17.
My questions are:
Why JVM does not search /Library/Java/Home/lib/ext for jar files?
Can we change CLASSPATH or java.ext.dirs property by modify any config file?
Any suggestion to solve this problem?
Thanks in advance.

I've had the same problem after upgrading to new Java version on Mac.
My (maven) project ran OK from command line but got the "SunTlsRsaPremasterSecret" error in Eclipse.
The solution was to remove Installed JREs in Eclipse configuration and add them again (using the "Search..." button).

had a similar issue. Adding the classpath to the ext directory fixed it for me. This fix worked for me on windows 7 with java 1.6
java -Djava.ext.dirs=lib -classpath "%java_home%\lib\ext\*" myapp.jar

I think we find the root cause so here is an answer of my own question.
the Java system property "java.ext.dirs" in Mac OS X 10.5 is:
/Library/Java/Extensions:/System/Library/Java/Extensions:/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/ext. The sunjce_provider.jar should be in /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/ext but also be found in /Library/Java/Extensions/ in the problem mac.
the sunjce_provider.jar in /Library/Java/Extensions/ belongs to Java Cryptography Extension(JCE) 1.2.2, which has been installed in the mac. JCE 1.2.2 is an optional package of J2SE 1.3.1 and may not includes enough libraries for J2SE 1.4 and later.
the Java applcation works normally after all JCE 1.2.2 related jar files have been removed from /Library/Java/Extensions/.

It happened to me while launching the tomcat server from eclipse. I solved it by changing the configuration in Windows -> Preferences -> Java -> Installed JREs -> Edit. I had to update all the JRE system libraries with the corresponding jars from the folders in:
%JAVA_HOME%/jre/lib/ext
%JAVA_HOME%/jre/lib/
It seems that after the last update I have changed the JRE_Home but forgot those libraries.

I also had this issue, noticed that the problem was in my Eclipse configuration.
Window > Preferences > Java > Installed JREs > jdk8_64bit > Edit...
The path of my sunjce_provider.jar was pointing to jdk8_64bit\lib\ext\sunjce.provider.jar. It should point to the JRE's equivalent in jdk8_64bit\jre\lib\ext\sunjce.provider.jar.

Had to spend almost a day on this while trying to use JavaMail in Eclipse Luna.
Tried all approaches suggested in various forums, but no luck.
Digged into the complete flow and found the exception arising due to Class is on BootClassPath
from KeyAgreement.getInstance()->JceSecurity.canUseProvider()->JceSecurity.getVerificationResult()->JarVerifier.verify()
void verify()
throws JarException, IOException
{
if (jarURL == null) {
throw new JarException("Class is on the bootclasspath");
}.......
I removed sunjce_provider jar from \ext\ folder and can send mail now.
This might not be right but atleast a quick workaround.
Refer Eclipse bug.

I know, I am joining late here. But for me, this error came suddenly as soon as I changed the Preference -> Java -> Installed JREs -> Execution Environments as JavaSE-1.8 to jdk1.8 path. But it should be jre1.8 path.
I don't know why is it happening now. But It sorted the problem.

Probable solution: Check if jdk path is set till C:\Program Files\Java\jdk1.8.0_171 but not including bin

In my case, I got above same issue, after reading above solutions, I changed JRE Definition and Restore Default. It is working fine now.

Related

UnsatisfiedLinkError for tomcat7 windowsOS

I am getting below error on my web app.
java.lang.UnsatisfiedLinkError: Can't obtain updateLastError method for class com.sun.jna.Native
com.sun.jna.Native.initIDs(Native Method)
com.sun.jna.Native.<clinit>(Native.java:139)
com.sun.jna.Pointer.<clinit>(Pointer.java:41)
com.sun.jna.platform.win32.WinNT$HANDLEByReference.<init>(WinNT.java:1114)
com.sun.jna.platform.win32.WinNT$HANDLEByReference.<init>(WinNT.java:1110)
waffle.windows.auth.impl.WindowsAuthProviderImpl.logonDomainUserEx(WindowsAuthProviderImpl.java:193)
waffle.windows.auth.impl.WindowsAuthProviderImpl.logonDomainUser(WindowsAuthProviderImpl.java:181)
waffle.windows.auth.impl.WindowsAuthProviderImpl.logonUser(WindowsAuthProviderImpl.java:212)
waffle.apache.MixedAuthenticator.post(MixedAuthenticator.java:233)
waffle.apache.MixedAuthenticator.authenticate(MixedAuthenticator.java:112)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:577)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
I searched that it may be due to some old version access of jna but removing jna is giving me NoClassDefErrors for com.sun.jna.Pointer. Also tried -Djna.nosys=true but its also not solving the issue.
I also tried -Djava.library.path=
from What is the cause of an UnsatisfiedLinkError? but it is also not working..
Any suggestion is highly appreciated.
I resolved this by deleting an old jnidispatch.dll file from my machine.
I'm using Gradle and Tomcat on Windows 7.
Delete the jnidispatch.dll file in C:\Users\<username>\.gradle\native\jna\win32-amd64
Don't have enough rep to just comment, but this is vaguely similar to a question i asked a couple years ago called UnsatisfiedLinkError, despite setting Djava.library.path variable
Somebody suggested making sure i was using the right architecture type, i.e. using 64 bit jdk with 64 bit Tomcat & 32 with 32. Does that match up?

My Pivotal tc Server not Start

Until a few days ago, my STS worked perfectly, but of a sudden, the Pivotal server does not start, throws me the following error message when you run an application:
SEVERE: Class loader creation threw exception
java.io.IOException: The filename, directory name, or volume label syntax is incorrect
at java.io.WinNTFileSystem.canonicalize0 (Native Method)
at java.io.Win32FileSystem.canonicalize (Win32FileSystem.java: 414)
at java.io.File.getCanonicalPath (File.java: 618)
at java.io.File.getCanonicalFile (File.java: 643)
at org.apache.catalina.startup.ClassLoaderFactory.createClassLoader (ClassLoaderFactory.java: 170)
at org.apache.catalina.startup.Bootstrap.createClassLoader (Bootstrap.java: 149)
at org.apache.catalina.startup.Bootstrap.initClassLoaders (Bootstrap.java: 90)
at org.apache.catalina.startup.Bootstrap.init (Bootstrap.java: 226)
at org.apache.catalina.startup.Bootstrap.main (Bootstrap.java: 425)
They could help me with this problem?
From already, thank you very much for your attention and time.
Gustavo Echenique
I had the same error on Tomcat 6 (Pivotal 3.0, STS) and my problem was in catalina.properties. The "common.loader" property was incorrectly using Tomcat 8 style and it was as follows:
common.loader = \
\"${catalina.base}/lib\",\
\"${catalina.base}/lib/*.jar\",\
\"${catalina.home}/lib\",\
\"${catalina.home}/lib/*.jar\"
I have removed the double quotes and that fixed the problem. Correct definition:
common.loader = \
${catalina.base}/lib,\
${catalina.base}/lib/*.jar,\
${catalina.home}/lib,\
${catalina.home}/lib/*.jar
Also, STS has quietly added Tomcat 8 JARs (bootstrap.jar, etc) to my Tomcat 6 launch configuration. While I had these JARs on the classpath, everything worked fine. But once I discovered and removed them, Tomcat 6 started breaking with the error in the original post.
I started to have the same issue out of nothing as well. We are using Java 1.7 in our project, but I also have Java 8 installed on my machine for experimenting. Even though everything is still configured to use 1.7 (I never changed the configuration and it was working fine), I think after some Java 8 update I started to get this issue.
After trying several things, I decided to uninstall all Java 8 related updates and installations; and made a fresh installation of Spring STS 3.6.2 with a new workspace. It seems to be working fine right now. You can try this if you also have a similar environment.

Unable to launch cygpath

I am new to openCV and I downloaded it to work with it in Eclipse Juno.
I have download version 2.4.6 and I have download NDK version R9 and I am working on windows platform and still can't run the tutorials of openCV because of the following errors. I followed the steps on this documentation .
I tried to change the path on the build path part (C:\android-ndk\android-ndk-r9\ndk-build.cmd NDK_DEBUG=1)
[2013-10-29 18:06:56 - Unable to launch cygpath. Is Cygwin on the path?] java.io.IOException: Cannot run program "cygpath": CreateProcess error=2, The system cannot find the file specified
[2013-10-29 18:07:12 - ManagerActivity] Manifest attribute 'minSdkVersion' is set to '#ANDROID_NATIVE_API_LEVEL#'. Integer is expected.
[2013-10-29 18:07:13 - package] Manifest attribute 'minSdkVersion' is set to '#ANDROID_SDK_VERSION#'. Integer is expected.
I don't think you need Cygwin when using NDK-R9. I think it was integrated in with R8 (or whatever they did to get around it). So you can ignore that error. I get that error as well, I'm looking how to get rid of it. But this error does not stop me from compiling. I've been ignoring it.
As far as the other two errors, they mention it needs an integer value. You need to put this element into your Manifest.xml file:
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="18" />
... Or use the API level range you plan to comply with
i fixed the problem which was:
NDK version r9 .. has some issues so i have installed version r8b which solved the problem and worked fine .. :))

Weird problem using sun.security.pkcs11.SunPKCS11: The specified procedure could not be found?

I'm developing this application to be used speceifically with Firefox (it's for internal use). Basically, we're using the sun.security stuff to read Firefox's KeyStore and sign data with the certs we get.
I've tested this on several machines and the results are varying, I can't seem to pinpoint the reason.
I've tested it on the latest ubuntu release, Firefox 3.6.13, using Java version 1.6.0_22, it works there. I also have a Windows XP laptop with the same Firefox version using Java version 1.6.0_17, where it works as well.
There are 2 other Windows XP laptops that it will not work on, giving the same error. They're running the same version of Firefox and using java version 1.6.0_17.
The error is:
java.security.ProviderException: Could not initialize NSS
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:183)
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:86)
at SignedMessage.SigningApplet.initializeCrypto(SigningApplet.java:327)
at SignedMessage.SigningApplet.init(SigningApplet.java:84)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: The specified procedure could not be found.
at sun.security.pkcs11.Secmod.nssLoadLibrary(Native Method)
at sun.security.pkcs11.Secmod.initialize(Secmod.java:186)
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:179)
... 5 more
Exception: java.security.ProviderException: Could not initialize NSS
From what I can tell it can't find the native nssLoadLibrary routine? The configuration file is pointing it to the Firefox install directory (where it can grab the nss3.dll or libnss3.so file). It does this across all pc's and all the paths in the configuration seem to be valid.
A sample config file, for what it's worth:
name=NSS
nssDbMode=readOnly
nssModule=keystore
nssSecmodDirectory="C:\\Documents and Settings\\user\\Application Data\\Mozilla\\firefox\\Profiles/8bzd2qqm.default"
nssLibraryDirectory=C:\Program Files\Mozilla Firefox
I was hoping someone would have a clue, or maybe some tips on getting further with debugging. I'm at a loss here.
I'm likely much too late for this to be of use to you, but I was having similar problems, and adding dist\WINXXX_DBG.OBJ\lib to my PATH resolved this issue.
Quick answer: Use the x86 jdk not the x64 jdk with NSS and JSS
Quick test against a NSS certificate database:
keytool -list -v -storetype pkcs11 -providerClass sun.security.pkcs11.SunPKCS11 -providerArg NSS_CONFIG_FIPS
where NSS_CONFIG_FIPS is the path to a config file pointing to an NSS database. This command will fail with a stack trace that matches the questioners error if it is a JDK issue and succeed if the JDK is configured properly (and if the config file is correct)
Note that my stack trace included the message:
Caused by: java.io.IOException: %1 is not a valid Win32 application.
I ran dumpbin /headers on the NSS dlls and found that the Mozilla built binaries are all 32 bit. I installed the x86 jdk and repointed JAVA_HOME. Everything began working.
To Vivek's point, NSS and the accompanying executables are very sensitive to the presence of the libraries. Be sure all of the .dll, .lib, and .chk files are present on the path. In particular, modutil.exe will fail certain commands without the chk files and the error messages are not helpful. Your NSS lib folder will need to include the NSS and NSPR lib folders, the jss4.dll and jss4.lib files, and the jss4.jar.
Also note that if you build NSS yourself, the libaries will not be signed with an approved code signing cert which will cause problems with JCA.

Hibernate fails with NullPointerException in EntityTuplizerFactory.constructTuplizer? Why?

I have a problem when I try to instantiate Hibernate and connect with a MySQL database (see error message below).
Curiously enough the connection works fine using the exact same hibernate.cfg.xml file when running Junit tests but it refuses to work when run from Tomcat...
I am starting to run out of ideas.
Any clues or tip where to look?
Caused by: org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.DynamicMapEntityTuplizer]
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:110)
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructDefaultTuplizer(EntityTuplizerFactory.java:135)
at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.(EntityEntityModeToTuplizerMapping.java:69)
at org.hibernate.tuple.entity.EntityMetamodel.(EntityMetamodel.java:323)
at org.hibernate.persister.entity.AbstractEntityPersister.(AbstractEntityPersister.java:456)
at org.hibernate.persister.entity.SingleTableEntityPersister.(SingleTableEntityPersister.java:131)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:84)
at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:267)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341)
at se.fmt.atlantism.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:16)
... 38 more
Caused by: java.lang.NullPointerException
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:107)
... 47 more
I'm writing this for future Googlers and reference.
I've done some more research and the root source of the problem is still not known. However the following article throw me on the right track.
http://www.howtogeek.com/howto/linux/installing-tomcat-6-on-ubuntu/
It seems like the Tomcat (version 6 at least) packages available in Ubuntu (and Debian) are not working correctly. Instead I installed Tomcat using the following guide:
http://www.ctrip.ufl.edu/tomcat6-debian-lenny-howto
While this might not be the premium choice of installation it seems necessary to get Tomcat version 6 running without problems on Ubuntu and/or Debian Lenny.
In my case, this error was resolved by switching the <dependency/> order in my pom.xml. When hibernate (3.2.7.ga) comes before hibernate-annotations (3.4.0.GA) this error occurs. The other way around, it works fine. This is the case even with scope=compile.
I would guess that you need to tweak your classpath, except that (assuming you've dropped both jars in WEB-INF/lib) it should alpha-sort in the correct order. But maybe this will give someone a hint on how to move forward.
In my case it was a simple mistake - the config file *.hbm.xml had a property that the mapped object didnt have! I also heard of cases of that error apearing when you misspell a get/set function - very similar to my case.
I was facing the same problem. It went away after I downloaded "javassist.jar" and put it in the classpath: http://www.java2s.com/Code/Jar/JKL/Downloadjavassistjar.htm
This is how the Tomcat daemon process looks:
root 2605 0.0 0.0 16584 376 ? Ss 15:39 0:00
/usr/bin/jsvc -user tomcat6
-cp /usr/share/java/commons-daemon.jar:/usr/share/tomcat6/bin/bootstrap.jar
-outfile SYSLOG -errfile SYSLOG -pidfile /var/run/tomcat6.pid
-Djava.awt.headless=true -Xmx128M
-Djava.endorsed.dirs=/usr/share/tomcat6/endorsed
-Dcatalina.base=/var/lib/tomcat6 -Dcatalina.home=/usr/share/tomcat6
-Djava.io.tmpdir=/tmp/tomcat6-temp -Djava.security.manager
-Djava.security.policy=/var/lib/tomcat6/work/catalina.policy
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.util.logging.config.file=/var/lib/tomcat6/conf/logging.properties
org.apache.catalina.startup.Bootstrap
This is how the Tomcat process looks when run from within Eclipse using the Sysdeo Tomcat launcher plugin:
(this one actually works)
jzaruba 2655 19.7 4.5 358304 46152 ? Sl 15:43 0:01
/usr/lib/jvm/java-6-sun-1.6.0.15/bin/java
-agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:37377
-Dcatalina.home=/usr/share/tomcat6
-Djava.endorsed.dirs=/usr/share/tomcat6/endorsed
-Dcatalina.base=/var/lib/tomcat6 -Djava.io.tmpdir=/var/lib/tomcat6/temp
-Dfile.encoding=UTF-8 -classpath
/usr/share/tomcat6/bin/bootstrap.jar:/usr/lib/jvm/java-6-sun-1.6.0.15/lib/tools.jar
org.apache.catalina.startup.Bootstrap start
The working one (Eclipse launched) is run using java-6-sun-1.6.0.15, I'm Windows user so I don't know how to tell which JRE is used for /usr/lib/jsvc (looking at it though), but my guess would be it is some OpenJDK... Could this be the difference?
update: jsvc probably uses the same JRE Sysdeo Tomcat launcher does

Categories

Resources