Closed muistar closed 4 years ago
在biz里直接使用
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
可以正常启动... 打断点到cat.class的if里就走不下去了.... private static void initializeInternal() { validate(); if (isEnabled()) { try { if (!init) { synchronized(instance) { if (!init) { producer = DefaultMessageProducer.getInstance(); } } } } catch (Exception var5) { errorHandler(var5); disable(); } }
}
配置是我们源码中自带的么?还是你改过了?需要配置cat的地址
也遇到了这个问题,直接clone的项目,没有做任何修改,应该是项目没有配置cat,然后走默认配置导致的,建议加上默认的cat配置。
更新最新的kitty install后不会出现此问题
java.lang.ExceptionInInitializerError: null at com.dianping.cat.message.internal.DefaultMessageManager.(DefaultMessageManager.java:45) ~[cat-client-3.0.0.jar:na]
at com.dianping.cat.message.internal.DefaultMessageManager.(DefaultMessageManager.java:52) ~[cat-client-3.0.0.jar:na]
at com.dianping.cat.message.internal.DefaultMessageProducer.(DefaultMessageProducer.java:33) ~[cat-client-3.0.0.jar:na]
at com.dianping.cat.message.internal.DefaultMessageProducer.(DefaultMessageProducer.java:37) ~[cat-client-3.0.0.jar:na]
at com.dianping.cat.Cat.initializeInternal(Cat.java:311) ~[cat-client-3.0.0.jar:na]
at com.dianping.cat.Cat.checkAndInitialize(Cat.java:72) ~[cat-client-3.0.0.jar:na]
at com.dianping.cat.Cat.getProducer(Cat.java:211) ~[cat-client-3.0.0.jar:na]
at com.dianping.cat.Cat.newTransaction(Cat.java:627) ~[cat-client-3.0.0.jar:na]
at com.cxytiandi.kitty.common.cat.CatTransactionManager.newTransaction(CatTransactionManager.java:22) ~[kitty-common-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
at com.alibaba.nacos.client.config.impl.HttpSimpleClient.httpGet(HttpSimpleClient.java:48) ~[kitty-register-nacos-1.0-SNAPSHOT.jar:na]
at com.alibaba.nacos.client.config.http.ServerHttpAgent.httpGet(ServerHttpAgent.java:80) ~[nacos-client-1.1.1.jar:na]
at com.alibaba.nacos.client.config.http.MetricsHttpAgent.httpGet(MetricsHttpAgent.java:48) ~[nacos-client-1.1.1.jar:na]
at com.alibaba.nacos.client.config.impl.ClientWorker.getServerConfig(ClientWorker.java:234) ~[nacos-client-1.1.1.jar:na]
at com.alibaba.nacos.client.config.NacosConfigService.getConfigInner(NacosConfigService.java:173) ~[nacos-client-1.1.1.jar:na]
at com.alibaba.nacos.client.config.NacosConfigService.getConfig(NacosConfigService.java:122) ~[nacos-client-1.1.1.jar:na]
at com.alibaba.cloud.nacos.client.NacosPropertySourceBuilder.loadNacosData(NacosPropertySourceBuilder.java:85) ~[spring-cloud-alibaba-nacos-config-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at com.alibaba.cloud.nacos.client.NacosPropertySourceBuilder.build(NacosPropertySourceBuilder.java:75) ~[spring-cloud-alibaba-nacos-config-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.loadNacosDataIfPresent(NacosPropertySourceLocator.java:179) ~[spring-cloud-alibaba-nacos-config-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.loadExtConfiguration(NacosPropertySourceLocator.java:129) ~[spring-cloud-alibaba-nacos-config-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.locate(NacosPropertySourceLocator.java:87) ~[spring-cloud-alibaba-nacos-config-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.initialize(PropertySourceBootstrapConfiguration.java:97) ~[spring-cloud-context-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:621) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:365) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:310) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1213) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1202) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at com.cxytiandi.kittycloud.article.provider.KittyCloudArticleProviderApp.main(KittyCloudArticleProviderApp.java:29) [classes/:na]
Caused by: java.lang.RuntimeException: Error when get cat router service, please contact cat support team for help!
at com.dianping.cat.configuration.ApplicationEnvironment.loadClientConfig(ApplicationEnvironment.java:151) ~[cat-client-3.0.0.jar:na]
at com.dianping.cat.configuration.DefaultClientConfigService.(DefaultClientConfigService.java:72) ~[cat-client-3.0.0.jar:na]
at com.dianping.cat.configuration.DefaultClientConfigService.(DefaultClientConfigService.java:52) ~[cat-client-3.0.0.jar:na]
... 27 common frames omitted
Caused by: java.net.UnknownHostException: org.cat
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184) ~[na:1.8.0_201]
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) ~[na:1.8.0_201]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_201]
at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_201]
at sun.net.NetworkClient.doConnect(NetworkClient.java:175) ~[na:1.8.0_201]
at sun.net.www.http.HttpClient.openServer(HttpClient.java:463) ~[na:1.8.0_201]
at sun.net.www.http.HttpClient.openServer(HttpClient.java:558) ~[na:1.8.0_201]
at sun.net.www.http.HttpClient.(HttpClient.java:242) ~[na:1.8.0_201]
at sun.net.www.http.HttpClient.New(HttpClient.java:339) ~[na:1.8.0_201]
at sun.net.www.http.HttpClient.New(HttpClient.java:357) ~[na:1.8.0_201]
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1220) ~[na:1.8.0_201]
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1156) ~[na:1.8.0_201]
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1050) ~[na:1.8.0_201]
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:984) ~[na:1.8.0_201]
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1564) ~[na:1.8.0_201]
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492) ~[na:1.8.0_201]
at com.dianping.cat.util.Urls$UrlIO.openStream(Urls.java:83) ~[cat-client-3.0.0.jar:na]
at com.dianping.cat.util.Urls$UrlIO.openStream(Urls.java:59) ~[cat-client-3.0.0.jar:na]
at com.dianping.cat.util.NetworkHelper.readFromUrlWithRetry(NetworkHelper.java:36) ~[cat-client-3.0.0.jar:na]
at com.dianping.cat.configuration.ApplicationEnvironment.loadRemoteClientConfig(ApplicationEnvironment.java:168) ~[cat-client-3.0.0.jar:na]
at com.dianping.cat.configuration.ApplicationEnvironment.loadClientConfig(ApplicationEnvironment.java:132) ~[cat-client-3.0.0.jar:na]
... 29 common frames omitted
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class com.dianping.cat.message.internal.DefaultMessageProducer at com.dianping.cat.Cat.initializeInternal(Cat.java:311) at com.dianping.cat.Cat.checkAndInitialize(Cat.java:72) at com.dianping.cat.Cat.getProducer(Cat.java:211) at com.dianping.cat.Cat.logError(Cat.java:394) at com.dianping.cat.logback.CatLogbackAppender.logError(CatLogbackAppender.java:51) at com.dianping.cat.logback.CatLogbackAppender.append(CatLogbackAppender.java:36) at com.dianping.cat.logback.CatLogbackAppender.append(CatLogbackAppender.java:28) at ch.qos.logback.core.AppenderBase.doAppend(AppenderBase.java:82) at ch.qos.logback.core.spi.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:51) at ch.qos.logback.classic.Logger.appendLoopOnAppenders(Logger.java:270) at ch.qos.logback.classic.Logger.callAppenders(Logger.java:257) at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:421) at ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java:383) at ch.qos.logback.classic.Logger.log(Logger.java:765) at org.apache.commons.logging.LogAdapter$Slf4jLocationAwareLog.error(LogAdapter.java:410) at org.springframework.boot.SpringApplication.reportFailure(SpringApplication.java:821) at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:796) at org.springframework.boot.SpringApplication.run(SpringApplication.java:321) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1213) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1202) at com.cxytiandi.kittycloud.article.provider.KittyCloudArticleProviderApp.main(KittyCloudArticleProviderApp.java:29)