• MongoDB查询报错:class com.mongodb.MongoSecurityException: Exception authenticating MongoCredential


      异常日志:

    2019-05-30 10:10:24,252 [http-nio-8080-exec-1] DEBUG [java.sql.Connection] - ooo Connection Opened
    2019-05-30 10:10:24,258 [http-nio-8080-exec-1] DEBUG [java.sql.PreparedStatement] - ==>  Executing: insert into client_config ( appid, uid, config, created_time, creater, client_type, status ) values ( ?, ?, ?, now(), ?, ?, ? ) 
    2019-05-30 10:10:24,259 [http-nio-8080-exec-1] DEBUG [java.sql.PreparedStatement] - ==> Parameters: 1234(String), wulinfeng(String), By continuing to use our website, you agree with our use of cookies in accordance with our Cookie Policy.You can reject cookies by changing your browser settings.(String), 系统管理员(String), 1(String), 1(String)
    key=business:businessclientconfig:1:1234:wulinfeng
    2019-05-30 10:10:24,960 [http-nio-8080-exec-1] DEBUG [java.sql.Connection] - ooo Connection Opened
    2019-05-30 10:10:24,961 [http-nio-8080-exec-1] DEBUG [java.sql.PreparedStatement] - ==>  Executing: select id,data_key,description,valid_time,status,created_time from cache_memcache_data where data_key like 'business:businessclientconfig:1:1234:wulinfeng%' 
    2019-05-30 10:10:24,961 [http-nio-8080-exec-1] DEBUG [java.sql.PreparedStatement] - ==> Parameters: 
    2019-05-30 10:12:02,921 [http-nio-8080-exec-1] INFO  [org.mongodb.driver.connection] - Closed connection [connectionId{localValue:10}] to localhost:27017 because there was a socket exception raised by this connection.
    2019-05-30 10:12:45,796 [http-nio-8080-exec-1] DEBUG [java.sql.Connection] - ooo Connection Opened
    2019-05-30 10:12:45,799 [http-nio-8080-exec-1] DEBUG [java.sql.PreparedStatement] - ==>  Executing: INSERT INTO log_web_exception ( op_user, op_user_name, error_level, page_name, class_name, method, input_params, log_desc, log_stack, create_time,source_type) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, now(),'1'); 
    2019-05-30 10:12:45,800 [http-nio-8080-exec-1] DEBUG [java.sql.PreparedStatement] - ==> Parameters: 系统管理员(String), admin(String), 1(String), 客户端配置(String), com.wlf.musicbox.business.controller.ClientConfigController(String), saveClientConfig(String), {"id":0,"appid":"1234","config":"By continuing to use our website, you agree with our use of cookies in accordance with our Cookie Policy.You can reject cookies by changing your browser settings.","creater":"系统管理员","status":"1","uid":"wulinfeng","clientType":"1"}(String), 保存客户端配置信息异常(String), class com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='', source='admin', password=<hidden>, mechanismProperties={}}
    类名: com.mongodb.internal.connection.SaslAuthenticator, 方法名: wrapException,行数: 173 
    类名: com.mongodb.internal.connection.SaslAuthenticator, 方法名: access$300,行数: 40 
    类名: com.mongodb.internal.connection.SaslAuthenticator$1, 方法名: run,行数: 70 
    类名: com.mongodb.internal.connection.SaslAuthenticator$1, 方法名: run,行数: 47 
    类名: com.mongodb.internal.connection.SaslAuthenticator, 方法名: doAsSubject,行数: 179 
    类名: com.mongodb.internal.connection.SaslAuthenticator, 方法名: authenticate,行数: 47 
    类名: com.mongodb.internal.connection.InternalStreamConnectionInitializer, 方法名: authenticateAll,行数: 151 
    类名: com.mongodb.internal.connection.InternalStreamConnectionInitializer, 方法名: initialize,行数: 64 
    类名: com.mongodb.internal.connection.InternalStreamConnection, 方法名: open,行数: 127 
    类名: com.mongodb.internal.connection.UsageTrackingInternalConnection, 方法名: open,行数: 50 
    类名: com.mongodb.internal.connection.DefaultConnectionPool$PooledConnection, 方法名: open,行数: 390 
    类名: com.mongodb.internal.connection.DefaultConnectionPool, 方法名: get,行数: 106 
    类名: com.mongodb.internal.connection.DefaultConnectionPool, 方法名: get,行数: 92 
    类名: com.mongodb.internal.connection.DefaultServer, 方法名: getConnection,行数: 85 
    类名: com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource, 方法名: getConnection,行数: 115 
    类名: com.mongodb.operation.OperationHelper, 方法名: withConnectionSource,行数: 460 
    com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='', source='admin', password=<hidden>, mechanismProperties={}}
    类名: com.mongodb.operation.OperationHelper, 方法名: withConnection,行数: 406 
    类名: com.mongodb.operation.FindOperation, 方法名: execute,行数: 696 
    类名: com.mongodb.operation.FindOperation, 方法名: execute,行数: 83 
    类名: com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor, 方法名: execute,行数: 179 
    类名: com.mongodb.client.internal.MongoIterableImpl, 方法名: execute,行数: 132 
    类名: com.mongodb.client.internal.MongoIterableImpl, 方法名: iterator,行数: 86 
    类名: com.ll.musicbox.commonlibmongo.MongoDBUtil, 方法名: findAllCommonRecordsWithFiled,行数: 539 
    类名: com.ll.musicbox.commonlibmongo.MongoDBUtil, 方法名: findAllCommonRecords,行数: 519 
    类名: com.wlf.musicbox.system.service.MemCacheService, 方法名: getMemFromMongoForBlur,行数: 287 
    类名: com.wlf.musicbox.business.service.CommonService, 方法名: delMemFromMongoForBlur,行数: 1025 
    类名: com.wlf.musicbox.business.service.CommonService, 方法名: delMemByKeyValue,行数: 1284 
    类名: com.wlf.musicbox.business.controller.ClientConfigController, 方法名: saveClientConfig,行数: 238 
    类名: sun.reflect.NativeMethodAccessorImpl, 方法名: invoke0,行数: -2 
    类名: sun.reflect.NativeMethodAccessorImpl, 方法名: invoke,行数: 62 
    类名: sun.reflect.DelegatingMethodAccessorImpl, 方法名: invoke,行数: 43 
    类名: java.lang.reflect.Method, 方法名: invoke,行数: 498 
        at com.mongodb.internal.connection.SaslAuthenticator.wrapException(SaslAuthenticator.java:173)
    类名: org.springframework.web.method.support.InvocableHandlerMethod, 方法名: invoke,行数: 212 
        at com.mongodb.internal.connection.SaslAuthenticator.access$300(SaslAuthenticator.java:40)
    类名: org.springframework.web.method.support.InvocableHandlerMethod, 方法名: invokeForRequest,行数: 126 
        at com.mongodb.internal.connection.SaslAuthenticator$1.run(SaslAuthenticator.java:70)
        at com.mongodb.internal.connection.SaslAuthenticator$1.run(SaslAuthenticator.java:47)
    类名: org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod, 方法名: invokeAndHandle,行数: 96 
        at com.mongodb.internal.connection.SaslAuthenticator.doAsSubject(SaslAuthenticator.java:179)
    类名: org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter, 方法名: invokeHandlerMethod,行数: 617 
    类名: org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter, 方法名: handleInternal,行数: 578 
        at com.mongodb.internal.connection.SaslAuthenticator.authenticate(SaslAuthenticator.java:47)
    类名: org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter, 方法名: handle,行数: 80 
        at com.mongodb.internal.connection.InternalStreamConnectionInitializer.authenticateAll(InternalStreamConnectionInitializer.java:151)
    类名: org.springframework.web.servlet.DispatcherServlet, 方法名: doDispatch,行数: 900 
        at com.mongodb.internal.connection.InternalStreamConnectionInitializer.initialize(InternalStreamConnectionInitializer.java:64)
    类名: org.springframework.web.servlet.DispatcherServlet, 方法名: doService,行数: 827 
        at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:127)
    类名: org.springframework.web.servlet.FrameworkServlet, 方法名: processRequest,行数: 882 
        at com.mongodb.internal.connection.UsageTrackingInternalConnection.open(UsageTrackingInternalConnection.java:50)
    类名: org.springframework.web.servlet.FrameworkServlet, 方法名: doPost,行数: 789 
        at com.mongodb.internal.connection.DefaultConnectionPool$PooledConnection.open(DefaultConnectionPool.java:390)
    类名: javax.servlet.http.HttpServlet, 方法名: service,行数: 660 
        at com.mongodb.internal.connection.DefaultConnectionPool.get(DefaultConnectionPool.java:106)
    类名: javax.servlet.http.HttpServlet, 方法名: service,行数: 741 
        at com.mongodb.internal.connection.DefaultConnectionPool.get(DefaultConnectionPool.java:92)
    类名: org.apache.catalina.core.ApplicationFilterChain, 方法名: internalDoFilter,行数: 231 
        at com.mongodb.internal.connection.DefaultServer.getConnection(DefaultServer.java:85)
    类名: org.apache.catalina.core.ApplicationFilterChain, 方法名: doFilter,行数: 166 
        at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.getConnection(ClusterBinding.java:115)
    类名: org.apache.tomcat.websocket.server.WsFilter, 方法名: doFilter,行数: 53 
        at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:460)
    类名: org.apache.catalina.core.ApplicationFilterChain, 方法名: internalDoFilter,行数: 193 
        at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:406)
    类名: org.apache.catalina.core.ApplicationFilterChain, 方法名: doFilter,行数: 166 
        at com.mongodb.operation.FindOperation.execute(FindOperation.java:696)
        at com.mongodb.operation.FindOperation.execute(FindOperation.java:83)
    类名: org.springframework.web.filter.CharacterEncodingFilter, 方法名: doFilterInternal,行数: 88 
        at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:179)
    类名: org.springframework.web.filter.OncePerRequestFilter, 方法名: doFilter,行数: 76 
        at com.mongodb.client.internal.MongoIterableImpl.execute(MongoIterableImpl.java:132)
        at com.mongodb.client.internal.MongoIterableImpl.iterator(MongoIterableImpl.java:86)
    类名: org.apache.catalina.core.ApplicationFilterChain, 方法名: internalDoFilter,行数: 193 
        at com.ll.musicbox.commonlibmongo.MongoDBUtil.findAllCommonRecordsWithFiled(MongoDBUtil.java:539)
    类名: org.apache.catalina.core.ApplicationFilterChain, 方法名: doFilter,行数: 166 
        at com.ll.musicbox.commonlibmongo.MongoDBUtil.findAllCommonRecords(MongoDBUtil.java:519)
    类名: com.wlf.musicbox.filter.HttpRequestFitler, 方法名: doFilter,行数: 44 
        at com.wlf.musicbox.system.service.MemCacheService.getMemFromMongoForBlur(MemCacheService.java:287)
    类名: org.apache.catalina.core.ApplicationFilterChain, 方法名: internalDoFilter,行数: 193 
        at com.wlf.musicbox.business.service.CommonService.delMemFromMongoForBlur(CommonService.java:1025)
    类名: org.apache.catalina.core.ApplicationFilterChain, 方法名: doFilter,行数: 166 
        at com.wlf.musicbox.business.service.CommonService.delMemByKeyValue(CommonService.java:1284)
    类名: org.apache.shiro.web.servlet.ProxiedFilterChain, 方法名: doFilter,行数: 61 
        at com.wlf.musicbox.business.controller.ClientConfigController.saveClientConfig(ClientConfigController.java:238)
    类名: org.apache.shiro.web.servlet.AdviceFilter, 方法名: executeChain,行数: 108 
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    类名: org.apache.shiro.web.servlet.AdviceFilter, 方法名: doFilterInternal,行数: 137 
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    类名: org.apache.shiro.web.servlet.OncePerRequestFilter, 方法名: doFilter,行数: 125 
        at java.lang.reflect.Method.invoke(Method.java:498)
    类名: org.apache.shiro.web.servlet.ProxiedFilterChain, 方法名: doFilter,行数: 66 
        at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:212)
    类名: org.apache.shiro.web.servlet.AbstractShiroFilter, 方法名: executeChain,行数: 449 
    类名: org.apache.shiro.web.servlet.AbstractShiroFilter$1, 方法名: call,行数: 365 
        at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
        at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
    类名: org.apache.shiro.subject.support.SubjectCallable, 方法名: doCall,行数: 90 
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
        at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
    类名: org.apache.shiro.subject.support.SubjectCallable, 方法名: call,行数: 83 
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
    类名: org.apache.shiro.subject.support.DelegatingSubject, 方法名: execute,行数: 383 
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    类名: org.apache.shiro.web.servlet.AbstractShiroFilter, 方法名: doFilterInternal,行数: 362 
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    类名: org.apache.shiro.web.servlet.OncePerRequestFilter, 方法名: doFilter,行数: 125 
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    类名: org.springframework.web.filter.DelegatingFilterProxy, 方法名: invokeDelegate,行数: 346 
    类名: org.springframework.web.filter.DelegatingFilterProxy, 方法名: doFilter,行数: 259 
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    类名: org.apache.catalina.core.ApplicationFilterChain, 方法名: internalDoFilter,行数: 193 
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    类名: org.apache.catalina.core.ApplicationFilterChain, 方法名: doFilter,行数: 166 
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    类名: org.apache.catalina.core.StandardWrapperValve, 方法名: invoke,行数: 199 
    类名: org.apache.catalina.core.StandardContextValve, 方法名: invoke,行数: 96 
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    类名: org.apache.catalina.authenticator.AuthenticatorBase, 方法名: invoke,行数: 475 
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    类名: org.apache.catalina.core.StandardHostValve, 方法名: invoke,行数: 140 
    类名: org.apache.catalina.valves.ErrorReportValve, 方法名: invoke,行数: 80 
        at com.wlf.musicbox.filter.HttpRequestFitler.doFilter(HttpRequestFitler.java:44)
    类名: org.apache.catalina.valves.AbstractAccessLogValve, 方法名: invoke,行数: 651 
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    类名: org.apache.catalina.core.StandardEngineValve, 方法名: invoke,行数: 87 
        at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
    类名: org.apache.catalina.connector.CoyoteAdapter, 方法名: service,行数: 342 
        at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
    类名: org.apache.coyote.http11.Http11Processor, 方法名: service,行数: 498 
        at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
    类名: org.apache.coyote.AbstractProcessorLight, 方法名: process,行数: 66 
        at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
    类名: org.apache.coyote.AbstractProtocol$ConnectionHandler, 方法名: process,行数: 796 
    类名: org.apache.tomcat.util.net.NioEndpoint$SocketProcessor, 方法名: doRun,行数: 1374 
        at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
    类名: org.apache.tomcat.util.net.SocketProcessorBase, 方法名: run,行数: 49 
        at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
    类名: java.util.concurrent.ThreadPoolExecutor, 方法名: runWorker,行数: 1142 
        at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
    类名: java.util.concurrent.ThreadPoolExecutor$Worker, 方法名: run,行数: 617 
        at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
    类名: org.apache.tomcat.util.threads.TaskThread$WrappingRunnable, 方法名: run,行数: 61 
        at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
        at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
    类名: java.lang.Thread, 方法名: run,行数: 745 
        at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
    (String)
        at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
    2019-05-30 10:12:45,814 [http-nio-8080-exec-1] ERROR [com.wlf.musicbox.business.controller.ClientConfigController] - 添加客户端配置异常:class com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='', source='admin', password=<hidden>, mechanismProperties={}}
        at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
        at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
    类名: com.mongodb.internal.connection.SaslAuthenticator, 方法名: wrapException,行数: 173 
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    类名: com.mongodb.internal.connection.SaslAuthenticator, 方法名: access$300,行数: 40 
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    类名: com.mongodb.internal.connection.SaslAuthenticator$1, 方法名: run,行数: 70 
    类名: com.mongodb.internal.connection.SaslAuthenticator$1, 方法名: run,行数: 47 
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    类名: com.mongodb.internal.connection.SaslAuthenticator, 方法名: doAsSubject,行数: 179 
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:475)
    类名: com.mongodb.internal.connection.SaslAuthenticator, 方法名: authenticate,行数: 47 
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
    类名: com.mongodb.internal.connection.InternalStreamConnectionInitializer, 方法名: authenticateAll,行数: 151 
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
    类名: com.mongodb.internal.connection.InternalStreamConnectionInitializer, 方法名: initialize,行数: 64 
        at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651)
    类名: com.mongodb.internal.connection.InternalStreamConnection, 方法名: open,行数: 127 
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    类名: com.mongodb.internal.connection.UsageTrackingInternalConnection, 方法名: open,行数: 50 
    类名: com.mongodb.internal.connection.DefaultConnectionPool$PooledConnection, 方法名: open,行数: 390 
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
    类名: com.mongodb.internal.connection.DefaultConnectionPool, 方法名: get,行数: 106 
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:498)
    类名: com.mongodb.internal.connection.DefaultConnectionPool, 方法名: get,行数: 92 
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    类名: com.mongodb.internal.connection.DefaultServer, 方法名: getConnection,行数: 85 
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:796)
    类名: com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource, 方法名: getConnection,行数: 115 
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1374)
    类名: com.mongodb.operation.OperationHelper, 方法名: withConnectionSource,行数: 460 
        at org.apache.tomcat.类名: com.mongodb.operation.OperationHelper, 方法名: withConnection,行数: 406 
    util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    类名: com.mongodb.operation.FindOperation, 方法名: execute,行数: 696 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    类名: com.mongodb.operation.FindOperation, 方法名: execute,行数: 83 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    类名: com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor, 方法名: execute,行数: 179 
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    类名: com.mongodb.client.internal.MongoIterableImpl, 方法名: execute,行数: 132 
        at java.lang.Thread.run(Thread.java:745)
    类名: com.mongodb.client.internal.MongoIterableImpl, 方法名: iterator,行数: 86 
    Caused by: com.mongodb.MongoCommandException: Command failed with error 18 (AuthenticationFailed): 'Authentication failed.' on server localhost:27017. The full response is { "ok" : 0.0, "errmsg" : "Authentication failed.", "code" : 18, "codeName" : "AuthenticationFailed" }
    类名: com.ll.musicbox.commonlibmongo.MongoDBUtil, 方法名: findAllCommonRecordsWithFiled,行数: 539 
        at com.mongodb.internal.connection.ProtocolHelper.getCommandFailureException(ProtocolHelper.java:179)
    类名: com.ll.musicbox.commonlibmongo.MongoDBUtil, 方法名: findAllCommonRecords,行数: 519 
        at com.mongodb.internal.connection.InternalStreamConnection.receiveCommandMessageResponse(InternalStreamConnection.java:299)
    类名: com.wlf.musicbox.system.service.MemCacheService, 方法名: getMemFromMongoForBlur,行数: 287 
        at com.mongodb.internal.connection.InternalStreamConnection.sendAndReceive(InternalStreamConnection.java:255)
    类名: com.wlf.musicbox.business.service.CommonService, 方法名: delMemFromMongoForBlur,行数: 1025 
        at com.mongodb.internal.connection.CommandHelper.sendAndReceive(CommandHelper.java:83)
    类名: com.wlf.musicbox.business.service.CommonService, 方法名: delMemByKeyValue,行数: 1284 
        at com.mongodb.internal.connection.CommandHelper.executeCommand(CommandHelper.java:33)
    类名: com.wlf.musicbox.business.controller.ClientConfigController, 方法名: saveClientConfig,行数: 238 
        at com.mongodb.internal.connection.SaslAuthenticator.sendSaslStart(SaslAuthenticator.java:130)
    类名: sun.reflect.NativeMethodAccessorImpl, 方法名: invoke0,行数: -2 
        at com.mongodb.internal.connection.SaslAuthenticator.access$100(SaslAuthenticator.java:40)
    类名: sun.reflect.NativeMethodAccessorImpl, 方法名: invoke,行数: 62 
        at com.mongodb.internal.connection.SaslAuthenticator$1.run(SaslAuthenticator.java:54)
    类名: sun.reflect.DelegatingMethodAccessorImpl, 方法名: invoke,行数: 43 
        ... 86 more
    类名: java.lang.reflect.Method, 方法名: invoke,行数: 498 
    类名: org.springframework.web.method.support.InvocableHandlerMethod, 方法名: invoke,行数: 212 
    类名: org.springframework.web.method.support.InvocableHandlerMethod, 方法名: invokeForRequest,行数: 126 
    类名: org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod, 方法名: invokeAndHandle,行数: 96 
    类名: org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter, 方法名: invokeHandlerMethod,行数: 617 
    类名: org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter, 方法名: handleInternal,行数: 578 
    类名: org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter, 方法名: handle,行数: 80 
    类名: org.springframework.web.servlet.DispatcherServlet, 方法名: doDispatch,行数: 900 
    类名: org.springframework.web.servlet.DispatcherServlet, 方法名: doService,行数: 827 
    类名: org.springframework.web.servlet.FrameworkServlet, 方法名: processRequest,行数: 882 
    类名: org.springframework.web.servlet.FrameworkServlet, 方法名: doPost,行数: 789 
    类名: javax.servlet.http.HttpServlet, 方法名: service,行数: 660 
    类名: javax.servlet.http.HttpServlet, 方法名: service,行数: 741 
    类名: org.apache.catalina.core.ApplicationFilterChain, 方法名: internalDoFilter,行数: 231 
    类名: org.apache.catalina.core.ApplicationFilterChain, 方法名: doFilter,行数: 166 
    类名: org.apache.tomcat.websocket.server.WsFilter, 方法名: doFilter,行数: 53 
    类名: org.apache.catalina.core.ApplicationFilterChain, 方法名: internalDoFilter,行数: 193 
    类名: org.apache.catalina.core.ApplicationFilterChain, 方法名: doFilter,行数: 166 
    类名: org.springframework.web.filter.CharacterEncodingFilter, 方法名: doFilterInternal,行数: 88 
    类名: org.springframework.web.filter.OncePerRequestFilter, 方法名: doFilter,行数: 76 
    类名: org.apache.catalina.core.ApplicationFilterChain, 方法名: internalDoFilter,行数: 193 
    类名: org.apache.catalina.core.ApplicationFilterChain, 方法名: doFilter,行数: 166 
    类名: com.wlf.musicbox.filter.HttpRequestFitler, 方法名: doFilter,行数: 44 
    类名: org.apache.catalina.core.ApplicationFilterChain, 方法名: internalDoFilter,行数: 193 
    类名: org.apache.catalina.core.ApplicationFilterChain, 方法名: doFilter,行数: 166 
    类名: org.apache.shiro.web.servlet.ProxiedFilterChain, 方法名: doFilter,行数: 61 
    类名: org.apache.shiro.web.servlet.AdviceFilter, 方法名: executeChain,行数: 108 
    类名: org.apache.shiro.web.servlet.AdviceFilter, 方法名: doFilterInternal,行数: 137 
    类名: org.apache.shiro.web.servlet.OncePerRequestFilter, 方法名: doFilter,行数: 125 
    类名: org.apache.shiro.web.servlet.ProxiedFilterChain, 方法名: doFilter,行数: 66 
    类名: org.apache.shiro.web.servlet.AbstractShiroFilter, 方法名: executeChain,行数: 449 
    类名: org.apache.shiro.web.servlet.AbstractShiroFilter$1, 方法名: call,行数: 365 
    类名: org.apache.shiro.subject.support.SubjectCallable, 方法名: doCall,行数: 90 
    类名: org.apache.shiro.subject.support.SubjectCallable, 方法名: call,行数: 83 
    类名: org.apache.shiro.subject.support.DelegatingSubject, 方法名: execute,行数: 383 
    类名: org.apache.shiro.web.servlet.AbstractShiroFilter, 方法名: doFilterInternal,行数: 362 
    类名: org.apache.shiro.web.servlet.OncePerRequestFilter, 方法名: doFilter,行数: 125 
    类名: org.springframework.web.filter.DelegatingFilterProxy, 方法名: invokeDelegate,行数: 346 
    类名: org.springframework.web.filter.DelegatingFilterProxy, 方法名: doFilter,行数: 259 
    类名: org.apache.catalina.core.ApplicationFilterChain, 方法名: internalDoFilter,行数: 193 
    类名: org.apache.catalina.core.ApplicationFilterChain, 方法名: doFilter,行数: 166 
    类名: org.apache.catalina.core.StandardWrapperValve, 方法名: invoke,行数: 199 
    类名: org.apache.catalina.core.StandardContextValve, 方法名: invoke,行数: 96 
    类名: org.apache.catalina.authenticator.AuthenticatorBase, 方法名: invoke,行数: 475 
    类名: org.apache.catalina.core.StandardHostValve, 方法名: invoke,行数: 140 
    类名: org.apache.catalina.valves.ErrorReportValve, 方法名: invoke,行数: 80 
    类名: org.apache.catalina.valves.AbstractAccessLogValve, 方法名: invoke,行数: 651 
    类名: org.apache.catalina.core.StandardEngineValve, 方法名: invoke,行数: 87 
    类名: org.apache.catalina.connector.CoyoteAdapter, 方法名: service,行数: 342 
    类名: org.apache.coyote.http11.Http11Processor, 方法名: service,行数: 498 
    类名: org.apache.coyote.AbstractProcessorLight, 方法名: process,行数: 66 
    类名: org.apache.coyote.AbstractProtocol$ConnectionHandler, 方法名: process,行数: 796 
    类名: org.apache.tomcat.util.net.NioEndpoint$SocketProcessor, 方法名: doRun,行数: 1374 
    类名: org.apache.tomcat.util.net.SocketProcessorBase, 方法名: run,行数: 49 
    类名: java.util.concurrent.ThreadPoolExecutor, 方法名: runWorker,行数: 1142 
    类名: java.util.concurrent.ThreadPoolExecutor$Worker, 方法名: run,行数: 617 
    类名: org.apache.tomcat.util.threads.TaskThread$WrappingRunnable, 方法名: run,行数: 61 
    类名: java.lang.Thread, 方法名: run,行数: 745 

      调用链有点长,关键看标黄那一行,无非admin数据库做用户验证失败了。先看看系统启动时建立MongoDB数据库连接时的用户名和密码设置:

                MongoDBUtil.getInstance().init(Cfg.get("configinfo.mongo.addr"),
                        Integer.valueOf(Cfg.get("configinfo.mongo.pool")),
                        3000, Cfg.get("configinfo.mongo.user"), Cfg.get    ("configinfo.mongo.pwd"), null);

      这里的配置均从application.properties文件中读取:

    configinfo.mongo.addr=localhost:27017
    configinfo.mongo.pool=20
    configinfo.mongo.user=
    configinfo.mongo.pwd=

      从上面看到我一开始并未设置用户名和密码,导致校验失败。那么我们来给admin设置一下用户名和密码:

    > use admin
    switched to db admin
    >  db.createUser({user:"wlf",pwd:"123",roles:["readWrite"]})
    Successfully added user: { "user" : "wlf", "roles" : [ "readWrite" ] }
    > db.auth("wlf","123")
    1

      对应的配置项也改下:

    configinfo.mongo.user=wlf
    configinfo.mongo.pwd=123

      然后重启下tomcat让配置生效,再跑下看看,这次没有再报错了。但有一点我觉得比较奇怪的是,我并未设置数据库为admin,为啥MongoDB默认就跑到admin了?看了MongoDBUtil类我才恍然大悟:

        public synchronized void initWithTimeOutAndIsAuth(String address, int poolSize, int timeOut, String user, String pwd, ReadPreference readPreference, boolean isAuth) throws UnknownHostException, MongoException {
            if (poolSize == -1) {
                poolSize = 200;
            }
    
            System.setProperty("MONGO.POOLSIZE", String.valueOf(poolSize));
            if (this.mongo == null) {
                List<ServerAddress> saddrs = new ArrayList();
                String[] addrs = address.split(";");
                String[] var13 = addrs;
                int var12 = addrs.length;
    
                for(int var11 = 0; var11 < var12; ++var11) {
                    String addr = var13[var11];
                    String[] tmp = addr.split(":");
                    if (tmp.length == 2) {
                        ServerAddress a = new ServerAddress(tmp[0], Integer.valueOf(tmp[1]));
                        saddrs.add(a);
                    }
                }
    
                Builder builder = new Builder();
                builder.connectionsPerHost(poolSize).connectTimeout(timeOut).socketTimeout(timeOut).heartbeatConnectTimeout(3000).heartbeatSocketTimeout(3000).serverSelectionTimeout(timeOut).maxWaitTime(timeOut).maxConnectionIdleTime(timeOut);
                if (readPreference != null) {
                    builder.readPreference(readPreference);
                }
    
                MongoClientOptions options = builder.build();
                MongoCredential mongoCredential = null;
                if (isAuth) {
                    mongoCredential = MongoCredential.createCredential(user, "admin", pwd.toCharArray());
                }
    
                if (saddrs.size() == 1) {
                    if (isAuth) {
                        this.mongo = new MongoClient((ServerAddress)saddrs.get(0), mongoCredential, options);
                    } else {
                        this.mongo = new MongoClient((ServerAddress)saddrs.get(0), options);
                    }
                } else if (isAuth) {
                    this.mongo = new MongoClient(saddrs, mongoCredential, options);
                } else {
                    this.mongo = new MongoClient(saddrs, options);
                }
            }
    
        }
  • 相关阅读:
    理解glance
    基于Kubernetes(k8s)的RabbitMQ 集群
    docker最佳实践-----美团点评的分享
    成功搭建云计算的关键技巧------过完年第一篇
    从SDN鼻祖Nicira到VMware NSX 网络虚拟化平台的简单探讨
    openstack多region介绍与实践---转
    openstack架构
    kvm网络虚拟化
    kvm虚拟化操作
    html-from提交表单
  • 原文地址:https://www.cnblogs.com/wuxun1997/p/10948615.html
Copyright © 2020-2023  润新知