2017-07-22 8 views
0

try-catchの例外が長時間(数分後でも)に到着している間に、出力ストリームがすぐにエラーを受け取るのはなぜですか?Hibernateエラーの待ち時間が長すぎる

私は、MongoデータベースとインターフェイスするHibernate OGMを使用しています。 問題は何ですか?それを修正する方法またはそれを理解するために私は何を勉強すべきですか?

ログイン時に、間違ったパラメータでデータベースにアクセスしようとしたとき。ここでストリームはcom.mongodb.MongoCommandExceptionが発生したことを警告します。アプリケーションコントロールはcom.mongodb.MongoTimeoutExceptionの後に返されます。以下は

System.out:それはオープンソースライブラリとして使用可能な場合

INFORMAZIONI: Exception in monitor thread while connecting to server <hidden>:27017 
com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=null, userName='daniele_cuomo', source='admin', password=<hidden>, mechanismProperties={}} 
    at com.mongodb.connection.SaslAuthenticator.wrapInMongoSecurityException(SaslAuthenticator.java:157) 
    at com.mongodb.connection.SaslAuthenticator.access$200(SaslAuthenticator.java:37) 
    at com.mongodb.connection.SaslAuthenticator$1.run(SaslAuthenticator.java:66) 
    at com.mongodb.connection.SaslAuthenticator$1.run(SaslAuthenticator.java:44) 
    at com.mongodb.connection.SaslAuthenticator.doAsSubject(SaslAuthenticator.java:162) 
    at com.mongodb.connection.SaslAuthenticator.authenticate(SaslAuthenticator.java:44) 
    at com.mongodb.connection.DefaultAuthenticator.authenticate(DefaultAuthenticator.java:32) 
    at com.mongodb.connection.InternalStreamConnectionInitializer.authenticateAll(InternalStreamConnectionInitializer.java:109) 
    at com.mongodb.connection.InternalStreamConnectionInitializer.initialize(InternalStreamConnectionInitializer.java:46) 
    at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:116) 
    at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:113) 
    at java.lang.Thread.run(Thread.java:745) 
Caused by: com.mongodb.MongoCommandException: Command failed with error 18: 'Authentication failed.' on server <hidden>:27017. The full response is { "ok" : 0.0, "code" : 18, "errmsg" : "Authentication failed." } 
    at com.mongodb.connection.CommandHelper.createCommandFailureException(CommandHelper.java:170) 
    at com.mongodb.connection.CommandHelper.receiveCommandResult(CommandHelper.java:123) 
    at com.mongodb.connection.CommandHelper.executeCommand(CommandHelper.java:32) 
    at com.mongodb.connection.SaslAuthenticator.sendSaslContinue(SaslAuthenticator.java:121) 
    at com.mongodb.connection.SaslAuthenticator.access$100(SaslAuthenticator.java:37) 
    at com.mongodb.connection.SaslAuthenticator$1.run(SaslAuthenticator.java:63) 
+0

エラーを追加できますか? – dilsingi

+0

追加、ありがとう! :) –

+0

これは有用な説明ではありません。完全なエラーを貼り付けることができますか?mongoシステムログから情報を取得することは可能ですか?また、タイムアウトエラーのように見えるので、タイムアウトまで待機します。私たちが完全な説明を得ているのでなければ、そのタイムアウトの理由を確かめることはできません。 – dilsingi

答えて

0

com.mongodb.MongoTimeoutExceptionは、このクラスに移動し、タイムアウト時間を変更します。ここで使用されているJava APIが何であるかも見てください。 ofcourseそれは、ここで使用されるjdk apiに依存します。例えば、MongoClientOption.Builder classから任意のプロパティで

hibernate.ogm.mongodb.driver.* 

あなたは置き換えることができます*:

0

次porpertyを使用してのMongoDBクライアントのプロパティを設定することができ

hibernate.ogm.mongodb.driver.connectTimeout 

official Hibernate OGM documentation containsすべての詳細

+0

ありがとう、私はすでにこのガイドを知っていた。しかし、エラーが発生したときにタイムアウトを待つ必要がないようにデータベースを構成したいと思います。私は、パスワードが間違っていることを(例えば)知っている場合、私はエラーを認識したいと思う、私はタイムアウトがある理由を理解していない。 –

+0

さらに、次の行を私のdependencies.xmlに追加してください: <プロパティ名= "hibernate.ogm.mongodb.driver.connectTimeout" value = "1" /> アプリケーションはまだ私をそんなに待っています –

+0

本当にHibernate OGMではなく、クライアントの設定に問題があります。 Hibernate OGMは単にmongo-java-driverライブラリを使ってクライアントを作成しています。あなたが渡したい設定の種類を教えていただけたら、すべてが期待通りに動いていることを確認できます。 – Davide

関連する問題