NutzCN Logo
问答 关于使用jdk1.8.0_162导致mongodb连接不上的问题
发布于 2381天前 作者 一叶孤舟 5545 次浏览 复制 上一个帖子 下一个帖子
标签:

你好:
一个后台jar程序,在idea中两个版本jdk(1.6,1.8)都是可以连接的,但是部署在linux下使用jdk1.6正常,使用jdk1.8就会报错,报错如下:

05-10 12:17:36.038 ERROR [main] - [数据库连接] : MongoDB连接错误, 请检查连接配置和数据库状态
com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=REPLICA_SET, servers=[{address=172.16.30.197:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='feitao', source='feitao', password=<hidden>, mechanismProperties={}}}, caused by {javax.security.sasl.SaslException: Unable to find PBKDF2WithHmacSHA1. [Caused by java.security.NoSuchAlgorithmException: PBKDF2WithHmacSHA1 SecretKeyFactory not available]}, caused by {java.security.NoSuchAlgorithmException: PBKDF2WithHmacSHA1 SecretKeyFactory not available}}, {address=172.16.30.200:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='feitao', source='feitao', password=<hidden>, mechanismProperties={}}}, caused by {javax.security.sasl.SaslException: Unable to find PBKDF2WithHmacSHA1. [Caused by java.security.NoSuchAlgorithmException: PBKDF2WithHmacSHA1 SecretKeyFactory not available]}, caused by {java.security.NoSuchAlgorithmException: PBKDF2WithHmacSHA1 SecretKeyFactory not available}}, {address=172.16.30.4:27017, type=REPLICA_SET_ARBITER, roundTripTime=0.6 ms, state=CONNECTED}]
	at com.mongodb.connection.BaseCluster.createTimeoutException(BaseCluster.java:369) ~[mongo-java-driver-3.2.2.jar:?]
	at com.mongodb.connection.BaseCluster.selectServer(BaseCluster.java:101) ~[mongo-java-driver-3.2.2.jar:?]
	at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:75) ~[mongo-java-driver-3.2.2.jar:?]
	at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:71) ~[mongo-java-driver-3.2.2.jar:?]
	at com.mongodb.binding.ClusterBinding.getReadConnectionSource(ClusterBinding.java:63) ~[mongo-java-driver-3.2.2.jar:?]
	at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:210) ~[mongo-java-driver-3.2.2.jar:?]
	at com.mongodb.operation.ListCollectionsOperation.execute(ListCollectionsOperation.java:172) ~[mongo-java-driver-3.2.2.jar:?]
	at com.mongodb.operation.ListCollectionsOperation.execute(ListCollectionsOperation.java:80) ~[mongo-java-driver-3.2.2.jar:?]
	at com.mongodb.Mongo.execute(Mongo.java:772) ~[mongo-java-driver-3.2.2.jar:?]
	at com.mongodb.Mongo$2.execute(Mongo.java:759) ~[mongo-java-driver-3.2.2.jar:?]
	at com.mongodb.OperationIterable.iterator(OperationIterable.java:47) ~[mongo-java-driver-3.2.2.jar:?]
	at com.mongodb.OperationIterable.forEach(OperationIterable.java:70) ~[mongo-java-driver-3.2.2.jar:?]
	at com.mongodb.MappingIterable.forEach(MappingIterable.java:50) ~[mongo-java-driver-3.2.2.jar:?]
	at com.mongodb.MappingIterable.into(MappingIterable.java:60) ~[mongo-java-driver-3.2.2.jar:?]
	at com.mongodb.DB.getCollectionNames(DB.java:253) ~[mongo-java-driver-3.2.2.jar:?]
	at com.mongodb.DB.collectionExists(DB.java:476) ~[mongo-java-driver-3.2.2.jar:?]
	at org.nutz.mongo.ZMoDB.cc(ZMoDB.java:46) ~[nutzmongo-1.r.63.jar:?]
	at com.nari.nwims.self.monitor.common.mongo.MongoIocBeanMaker.createZMoCo(MongoIocBeanMaker.java:148) ~[nwims-self-monitor.jar:?]
	at com.nari.nwims.self.monitor.common.mongo.MongoIocBeanMaker.makeMongoIocBean(MongoIocBeanMaker.java:108) ~[nwims-self-monitor.jar:?]
	at com.nari.nwims.self.monitor.common.mongo.MongoIocBeanMaker.initializeMongo(MongoIocBeanMaker.java:79) ~[nwims-self-monitor.jar:?]
	at com.nari.nwims.self.monitor.common.mongo.MongoIocBeanMaker.initializeMongoManyTimes(MongoIocBeanMaker.java:62) [nwims-self-monitor.jar:?]
	at com.nari.nwims.self.monitor.common.mongo.MongoIocBeanMaker.access$000(MongoIocBeanMaker.java:24) [nwims-self-monitor.jar:?]
	at com.nari.nwims.self.monitor.common.mongo.MongoIocBeanMaker$1.run(MongoIocBeanMaker.java:53) [nwims-self-monitor.jar:?]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_162]

7 回复

驱动版本问题吧

我的驱动版本是3.2.2的

<mongo.java.driver.version>3.2.2</mongo.java.driver.version>

是openjdk吗?

我的jdk是官方下载的jdk,不是openjdk

试试把nutzmongo更新一下

你好 请问你的问题是怎么解决的 我用idea 启动项目 没问题 等部到 linux上 连接mongodb
Caused by: javax.security.sasl.SaslException: Unable to find PBKDF2WithHmacSHA1.
at com.mongodb.connection.ScramSha1Authenticator$ScramSha1SaslClient.hi(ScramSha1Authenticator.java:230) ~[mongo-java-driver-3.6.2.jar!/:na]
at com.mongodb.connection.ScramSha1Authenticator$ScramSha1SaslClient.computeClientFinalMessage(ScramSha1Authenticator.java:167) ~[mongo-java-driver-3.6.2.jar!/:na]
at com.mongodb.connection.ScramSha1Authenticator$ScramSha1SaslClient.evaluateChallenge(ScramSha1Authenticator.java:100) ~[mongo-java-driver-3.6.2.jar!/:na]
at com.mongodb.connection.SaslAuthenticator$1.run(SaslAuthenticator.java:57) ~[mongo-java-driver-3.6.2.jar!/:na]
... 9 common frames omitted
Caused by: java.security.NoSuchAlgorithmException: PBKDF2WithHmacSHA1 SecretKeyFactory not available

添加回复
请先登陆
回到顶部