0

我在 Jelastic 上有一个环境,他们的支持无法提供帮助:P

我使用 java 8 和 MongoDB 2.6.4 设置了 Tomcat 7.0.55 对于 mongo,我还设置了一个外部 ip,以便我可以从本地 tomcat 访问。

这里发生了什么,我能够运行我的本地 Tomcat 和 Jelastic 远程 Mongo DB 但是部署后,我从远程 mongo 获取此日志

2015-01-07T22:57:29.637+0000 [conn22208]  authenticate db: easylend {authenticate: 1, user: "cre8tech", nonce: "xxx", key: "xxx" }
2015-01-07T22:57:29.638+0000 [conn22208] Failed to authenticate cre8tech@easylend with mechanism MONGODB-CR: AuthenticationFailed keymismatch

我 1000% 确定凭证是正确的,因此该方法用于记录,因为我可以在本地使用它到他们的远程 mongo + 我可以通过使用来访问它

mongo XXXX.whelastic.net/{myDbName} --username {username} --password {password}

@Bean
@Override
public Mongo mongo() throws Exception {
    ServerAddress serverAdress = new ServerAddress(host, Integer.parseInt(port));  
    Mongo mongo = null;
    if (usr != null && !usr.isEmpty()) {
        MongoCredential credential = MongoCredential.createMongoCRCredential(usr, database, pwd.toCharArray());
        mongo = new MongoClient(serverAdress, Arrays.asList(credential));

    } else {
        mongo = new MongoClient(serverAdress);
    }

    mongo.setWriteConcern(WriteConcern.SAFE);

    return mongo;
}

登录tomcat只是说不能认证

com.mongodb.CommandFailureException: { "serverUsed" : "********" , "code" : 18 , "ok" : 0.0 , "errmsg" : "auth fails"}

我的理论是远程 Jelastic tomcat 可能包含一些干扰我使用的 mongo 驱动程序的 jar/libs

感谢您的帮助

4

1 回答 1

0

不再需要搜索我发现了问题

Jelastic 上的 tomcat 继承自一些 linux 命令,例如 pwd,用于显示当前目录,我在属性中使用 pwd 检索密码。它不应该发生冲突,但确实会发生冲突,并且我将 /opt/tomcat 作为密码而不是我的密码

这可能是您最终需要修复的问题,因此这些变量不会与文件属性混合

解决方法是使用不同的属性名称

同样适用于亚马逊豆茎

谢谢

于 2015-01-09T17:05:09.523 回答