问题:
- 这两天在集成美团点评cat监控平台时,一直报错,无法上报信息。
解决过程:
- 一开始以为是配置文件配置有问题,找了半天没发现啥问题
- 又想着是不是jar包冲突的问题,因为看到有人说netty版本的问题,不过试了一下不管用
- 因为是比较老的项目,不知道是不是有其他jar包影响到了cat,于是新建了个springboot项目,同样的配置,通过Application#main方法居然成功了,说明配置没问题。一个是springboot、一个是普通spring项目感觉也没啥差别。。。
半天过去了,没辙了,,,后来第二天google了一下,就找到个cat的issue:https://github.com/dianping/cat/issues/1071,有个回复说是使用了tomcat7插件启动就会有问题,改成jetty、tomcat容器就可以了。
试了一下就可以了,,,,具体原因没细分析。
所以解决方法之一:
- 使用tomcat容器启动项目,而不是tomcat7的maven插件
报错信息如下:
java.lang.RuntimeException: Unable to get instance of Logger, please make sure the environment was setup correctly!
at org.unidal.initialization.DefaultModuleContext.setup(DefaultModuleContext.java:122)
at org.unidal.initialization.DefaultModuleContext.<init>(DefaultModuleContext.java:30)
at com.dianping.cat.Cat.initialize(Cat.java:199)
at com.dianping.cat.Cat.checkAndInitialize(Cat.java:79)
at com.dianping.cat.Cat.getProducer(Cat.java:177)
at com.dianping.cat.Cat.logEvent(Cat.java:325)
at redis.clients.jedis.Connection.sendCommand(Connection.java:90)
at redis.clients.jedis.BinaryClient.ping(BinaryClient.java:88)
at redis.clients.jedis.BinaryJedis.ping(BinaryJedis.java:79)
at redis.clients.jedis.JedisFactory.validateObject(JedisFactory.java:100)
at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:488)
at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:361)
at redis.clients.util.Pool.getResource(Pool.java:51)
at redis.clients.jedis.JedisPool.getResource(JedisPool.java:99)
at suishen.redis.SuishenRedis.getClient(SuishenRedis.java:133)
at suishen.redis.SuishenRedis.isAlive(SuishenRedis.java:151)
at suishen.libs.session.store.RedisSessionStore.<init>(RedisSessionStore.java:42)
at suishen.libs.session.store.RedisSessionStore.<init>(RedisSessionStore.java:50)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:142)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:122)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:271)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1193)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1095)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
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.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1531)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1276)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
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:761)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
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$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266)
at java.util.concurrent.FutureTask.run(FutureTask.java)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.codehaus.plexus.component.repository.exception.ComponentLookupException: Component descriptor cannot be found in the component repository
role: org.codehaus.plexus.logging.LoggerManager
roleHint:
classRealm: none specified
at org.codehaus.plexus.DefaultComponentRegistry.getComponentManager(DefaultComponentRegistry.java:435)
at org.codehaus.plexus.DefaultComponentRegistry.getComponent(DefaultComponentRegistry.java:353)
at org.codehaus.plexus.DefaultComponentRegistry.lookup(DefaultComponentRegistry.java:178)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:383)
at org.unidal.initialization.DefaultModuleContext.setup(DefaultModuleContext.java:118)
... 58 more