与MongoDB的Jelastic连接不工作在远程tomcat上,但当本地tomcat连接到远程Mongo时确定

时间:2015-01-08 22:51:02

标签: java mongodb tomcat authentication jelastic

我有一个关于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

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

不再需要搜索 我找到了问题

Jelastic上的tomcat继承了一些linux命令,例如用于显示当前目录的pwd 我在我的属性中使用pwd来检索密码。 它不应该碰撞,但确实如此,我将/ opt / tomcat作为密码而不是我的密码

这可能是您需要在最后修复的内容,因此这些变量不会与文件属性混合

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

同样适用于Amazon beanstalk

由于

相关问题