https://blog.csdn.net/zzq900503/article/details/54931456
单点登录(十)-----遇到问题-----cas启用mongodb验证方式报错com.mongodb.CommandFailureException---Authentication failed
2017年02月08日 19:34:52 张小凡vip 阅读数:8037更多
所属专栏: 单点登录运用和解析
版权声明:本文为博主原创文章,未经博主允许不得转载。https://blog.csdn.net/q383965374/article/details/54931456
cas启用mongodb验证方式报错com.mongodb.CommandFailureException---Authentication failed。
完整报错信息:
二月08,20175:34:32下午 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
2017-02-0817:34:39,577INFO [org.jasig.cas.services.DefaultServicesManagerImpl] -
2017-02-0817:34:40,186INFO [org.jasig.cas.services.DefaultServicesManagerImpl] -
2017-02-0817:34:43,445WARN [org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler] -
2017-02-0817:34:44,182INFO [org.jasig.cas.ticket.registry.TicketRegistryCleaner] -
2017-02-0817:34:44,183INFO [org.jasig.cas.ticket.registry.TicketRegistryCleaner] -
2017-02-0817:34:44,506WARN [org.jasig.cas.util.NoOpCipherExecutor] - <[org.jasig.cas.util.NoOpCipherExecutor] does no encryption and may NOT be safe in a production environment. Consider using other choices, such as [org.jasig.cas.util.BaseStringCipherExecutor] that handle encryption, signing and verification of all appropriate values.>
2017-02-0817:34:44,592WARN [org.jasig.cas.util.TGCCipherExecutor] -
2017-02-0817:34:44,601WARN [org.jasig.cas.util.TGCCipherExecutor] -
2017-02-0817:34:44,601WARN [org.jasig.cas.util.TGCCipherExecutor] -
2017-02-0817:34:44,601WARN [org.jasig.cas.util.TGCCipherExecutor] -
2017-02-0817:34:44,640WARN [org.jasig.cas.util.WebflowCipherExecutor] -
2017-02-0817:34:44,640WARN [org.jasig.cas.util.WebflowCipherExecutor] -
2017-02-0817:34:44,641WARN [org.jasig.cas.util.WebflowCipherExecutor] -
2017-02-0817:34:44,642WARN [org.jasig.cas.util.WebflowCipherExecutor] -
2017-02-0817:34:45,595WARN [org.springframework.web.context.support.XmlWebApplicationContext] -
2017-02-0817:34:46,054WARN [org.jasig.cas.services.JsonServiceRegistryConfigWatcher] -
2017-02-0817:34:46,057ERROR [org.springframework.web.context.ContextLoader] -
org.springframework.beans.factory.BeanCreationException: Error creating bean with name'mongoServiceRegistryDao': Invocation of init method failed; nested exception is org.springframework.dao.PermissionDeniedDataAccessException: {"serverUsed":"192.168.30.249:27017","ok":0.0,"code":18,"errmsg":"Authentication failed."}; nested exception is com.mongodb.CommandFailureException: {"serverUsed":"192.168.30.249:27017","ok":0.0,"code":18,"errmsg":"Authentication failed."}
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:136)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:778)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1113)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1671)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.springframework.dao.PermissionDeniedDataAccessException: {"serverUsed":"192.168.30.249:27017","ok":0.0,"code":18,"errmsg":"Authentication failed."}; nested exception is com.mongodb.CommandFailureException: {"serverUsed":"192.168.30.249:27017","ok":0.0,"code":18,"errmsg":"Authentication failed."}
at org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:99)
at org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:2013)
at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:448)
at org.springframework.data.mongodb.core.MongoTemplate.collectionExists(MongoTemplate.java:516)
at org.jasig.cas.services.MongoServiceRegistryDao.init(MongoServiceRegistryDao.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:354)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:305)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:133)
...27more
Caused by: com.mongodb.CommandFailureException: {"serverUsed":"192.168.30.249:27017","ok":0.0,"code":18,"errmsg":"Authentication failed."}
at com.mongodb.CommandResult.getException(CommandResult.java:76)
at com.mongodb.CommandResult.throwOnError(CommandResult.java:140)
at com.mongodb.DBPort$SaslAuthenticator.authenticate(DBPort.java:899)
at com.mongodb.DBPort.authenticate(DBPort.java:432)
at com.mongodb.DBPort.checkAuth(DBPort.java:443)
at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:289)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:269)
at com.mongodb.DBCollectionImpl.find(DBCollectionImpl.java:84)
at com.mongodb.DB.command(DB.java:320)
at com.mongodb.DB.command(DB.java:299)
at com.mongodb.DB.command(DB.java:388)
at com.mongodb.DBApiLayer.getCollectionNames(DBApiLayer.java:152)
at com.mongodb.DB.collectionExists(DB.java:524)
at org.springframework.data.mongodb.core.MongoTemplate$6.doInDB(MongoTemplate.java:518)
at org.springframework.data.mongodb.core.MongoTemplate$6.doInDB(MongoTemplate.java:516)
at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:446)
...36more
>
二月08,20175:34:46下午 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance ofclassorg.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'mongoServiceRegistryDao':Invocationofinitmethodfailed; nested exception is org.springframework.dao.PermissionDeniedDataAccessException: {"serverUsed":"192.168.30.249:27017","ok":0.0,"code":18,"errmsg":"Authentication failed."}; nested exception is com.mongodb.CommandFailureException: {"serverUsed":"192.168.30.249:27017","ok":0.0,"code":18,"errmsg":"Authentication failed."}
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:136)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:778)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1113)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1671)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.springframework.dao.PermissionDeniedDataAccessException: {"serverUsed":"192.168.30.249:27017","ok":0.0,"code":18,"errmsg":"Authentication failed."}; nested exception is com.mongodb.CommandFailureException: {"serverUsed":"192.168.30.249:27017","ok":0.0,"code":18,"errmsg":"Authentication failed."}
at org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:99)
at org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:2013)
at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:448)
at org.springframework.data.mongodb.core.MongoTemplate.collectionExists(MongoTemplate.java:516)
at org.jasig.cas.services.MongoServiceRegistryDao.init(MongoServiceRegistryDao.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:354)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:305)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:133)
...27more
Caused by: com.mongodb.CommandFailureException: {"serverUsed":"192.168.30.249:27017","ok":0.0,"code":18,"errmsg":"Authentication failed."}
at com.mongodb.CommandResult.getException(CommandResult.java:76)
at com.mongodb.CommandResult.throwOnError(CommandResult.java:140)
at com.mongodb.DBPort$SaslAuthenticator.authenticate(DBPort.java:899)
at com.mongodb.DBPort.authenticate(DBPort.java:432)
at com.mongodb.DBPort.checkAuth(DBPort.java:443)
at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:289)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:269)
at com.mongodb.DBCollectionImpl.find(DBCollectionImpl.java:84)
at com.mongodb.DB.command(DB.java:320)
at com.mongodb.DB.command(DB.java:299)
at com.mongodb.DB.command(DB.java:388)
at com.mongodb.DBApiLayer.getCollectionNames(DBApiLayer.java:152)
at com.mongodb.DB.collectionExists(DB.java:524)
at org.springframework.data.mongodb.core.MongoTemplate$6.doInDB(MongoTemplate.java:518)
at org.springframework.data.mongodb.core.MongoTemplate$6.doInDB(MongoTemplate.java:516)
at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:446)
...36more
二月08,20175:34:46下午 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance ofclassorg.jasig.cas.CasEnvironmentContextListener
org.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'mongoServiceRegistryDao':Invocationofinitmethodfailed; nested exception is org.springframework.dao.PermissionDeniedDataAccessException: {"serverUsed":"192.168.30.249:27017","ok":0.0,"code":18,"errmsg":"Authentication failed."}; nested exception is com.mongodb.CommandFailureException: {"serverUsed":"192.168.30.249:27017","ok":0.0,"code":18,"errmsg":"Authentication failed."}
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:136)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSin
gletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:778)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1113)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1671)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.springframework.dao.PermissionDeniedDataAccessException: {"serverUsed":"192.168.30.249:27017","ok":0.0,"code":18,"errmsg":"Authentication failed."}; nested exception is com.mongodb.CommandFailureException: {"serverUsed":"192.168.30.249:27017","ok":0.0,"code":18,"errmsg":"Authentication failed."}
at org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:99)
at org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:2013)
at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:448)
at org.springframework.data.mongodb.core.MongoTemplate.collectionExists(MongoTemplate.java:516)
at org.jasig.cas.services.MongoServiceRegistryDao.init(MongoServiceRegistryDao.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:354)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:305)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:133)
...27more
Caused by: com.mongodb.CommandFailureException: {"serverUsed":"192.168.30.249:27017","ok":0.0,"code":18,"errmsg":"Authentication failed."}
at com.mongodb.CommandResult.getException(CommandResult.java:76)
at com.mongodb.CommandResult.throwOnError(CommandResult.java:140)
at com.mongodb.DBPort$SaslAuthenticator.authenticate(DBPort.java:899)
at com.mongodb.DBPort.authenticate(DBPort.java:432)
at com.mongodb.DBPort.checkAuth(DBPort.java:443)
at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:289)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:269)
at com.mongodb.DBCollectionImpl.find(DBCollectionImpl.java:84)
at com.mongodb.DB.command(DB.java:320)
at com.mongodb.DB.command(DB.java:299)
at com.mongodb.DB.command(DB.java:388)
at com.mongodb.DBApiLayer.getCollectionNames(DBApiLayer.java:152)
at com.mongodb.DB.collectionExists(DB.java:524)
at org.springframework.data.mongodb.core.MongoTemplate$6.doInDB(MongoTemplate.java:518)
at org.springframework.data.mongodb.core.MongoTemplate$6.doInDB(MongoTemplate.java:516)
at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:446)
...36more
二月08,20175:34:46下午 org.apache.catalina.core.StandardContext startInternal
严重: Error listenerStart
二月08,20175:34:46下午 org.apache.catalina.core.StandardContext startInternal
严重: Context [/cas] startup failed due to previous errors
二月08,20175:34:46下午 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
二月08,20175:34:46下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/cas] appears to have started a thread named [Log4j2-Log4j2Scheduled-1] but has failed to stop it. This is very likely to create a memory leak.
二月08,20175:34:46下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory F:\tomcat7\webapps\client2
二月08,20175:34:46下午 org.apache.catalina.loader.WebappClassLoader validateJarFile
信息: validateJarFile(F:\tomcat7\webapps\client2\WEB-INF\lib\jsp-api-2.1.jar) - jar not loaded. See Servlet Spec2.3, section9.7.2. Offendingclass:javax/el/Expression.class
二月 08, 2017 5:34:46 下午org.apache.catalina.loader.WebappClassLoadervalidateJarFile
信息:validateJarFile(F:\tomcat7\webapps\client2\WEB-INF\lib\servlet-api-2.5.jar) -jarnotloaded.SeeServletSpec2.3,section9.7.2.Offendingclass:javax/servlet/Servlet.class
SLF4J:Failedtoloadclass"org.slf4j.impl.StaticLoggerBinder".
SLF4J:Defaultingtono-operation(NOP)loggerimplementation
SLF4J:Seehttp://www.slf4j.org/codes.html#StaticLoggerBinderforfurtherdetails.
二月 08, 2017 5:34:47 下午org.apache.catalina.startup.HostConfigdeployDirectory
信息:DeployingwebapplicationdirectoryF:\tomcat7\webapps\ROOT
二月 08, 2017 5:34:47 下午org.apache.coyote.AbstractProtocolstart
信息:StartingProtocolHandler["http-apr-8080"]
二月 08, 2017 5:34:47 下午org.apache.coyote.AbstractProtocolstart
信息:StartingProtocolHandler["ajp-apr-8009"]
二月 08, 2017 5:34:47 下午org.apache.catalina.startup.Catalinastart
信息:Serverstartupin34194ms
{ "serverUsed" : "192.168.30.249:27017" , "ok" : 0.0 , "code" : 18 , "errmsg" : "Authentication failed."}
是一种比较常见的错误。
就是认证失败,帐号密码连接mongodb认证错误。
查看mongodb的log日志也可以得到相关信息:
I ACCESS [conn1914] SCRAM-SHA-1 authentication failed for on testCrm from client 192.168.30.39 ; BadValue: Incorrect SCRAM-SHA-1 user name: n=
log一般存放在/data/mongodb/log文件夹路径。
这种情况分两种:
一种是mongodb数据库本身有启用身份验证的,需要检查帐号密码是否正确。
最好的方式就是 在mongo shell里在需要连接的数据库上进行db.auth(user,password),返回1则正确,返回0失败。
或者
mongo --authenticationDatabase dbName -u user -p
既然没有启用身份验证,为什么这里又去验证了帐号密码呢,显然是我们的连接方式和连接语句有问题。
我们注意到cas server对mongodb的连接方式使用的是com.mongodb.MongoClientURI方式,也就是使用的uri。
<bean id="clientUri" class="com.mongodb.MongoClientURI" c:uri="mongodb://${mongodb.userId}:${mongodb.userPassword}@${mongodb.host}:${mongodb.port}/${cas.service.registry.mongo.db}" />
配置文件和情况如下:
这里我们就发现问题了。
我们是把user和password空着,但是在配置文件里还是把空当作帐号密码来认证了,所以报错了。
我们查看官网的文档:
https://docs.mongodb.com/manual/reference/connection-string/
发现帐号和密码是非必须的
所以com.mongodb.MongoClientURI连接mongodb当没有启用帐号认证,用户名和密码为空时,使用的连接语句应该是
<bean id="clientUri" class="com.mongodb.MongoClientURI" c:uri="mongodb://${mongodb.host}:${mongodb.port}/${cas.service.registry.mongo.db}" />
如图,不再报错了。