【servlet】严重: Exception starting filter [tracingFilter]
java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
出现这个问题,应该不是过滤器本身的问题,而是对web.xml相关内容了解的不够,可以参看:
http://www.cnblogs.com/JesseV/archive/2009/11/17/1605015.html
该错误说明ContextLoaderListener 没有注册,需要在web.xml文件中添加org.springframework.web.context.ContextLoaderListener,具体可以参看:http://blog.csdn.net/seng3018/article/details/6758860
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
在配置了ContextLoaderListener之后,需要添加applicationContext.xml文件,有两种方式:
第一种:直接将之放到/WEB-INF下,之在web.xml中声明一个listener。(名字必须为:applicationContext.xml)
第二种:将之放到classpath下,但是此时要在web.xml中加入,用它来指明你的applicationContext.xml的位置以供web容器来加载,在web.xml中添加如下内容:
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext-*.xml,classpath*:applicationContext-*.xml</param-value>
【spring-web】java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
【log】Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
<artifactId>log4j</artifactId>
【log】SLF4J: Failed to load class "org.slf4j.impl.StaticMDCBinder"
【dubbo】Caused by: javax.ws.rs.ProcessingException: RESTEASY003145: Unable to find a MessageBodyReader of content-type application/json;charset=UTF-8 and type class org.demo.bean.User
<artifactId>netty-all</artifactId>
<version>4.0.35.Final</version>
<artifactId>netty-all</artifactId>
<version>4.1.31.Final</version><!--$NO-MVN-MAN-VER$-->
【log】log4j:WARN No such property [datePattern] in org.apache.log4j.RollingFileAppender.
暂无根本解决方案,暂时放弃配置datePattern,改用DailyRollingFileAppender
【spring】org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'java.util.concurrent.ScheduledExecutorService' available
原来,Spring的定时任务调度器会尝试获取一个注册过的 task scheduler来做任务调度,它会尝试通过BeanFactory.getBean的方法来获取一个注册过的scheduler bean,获取的步骤如下:
1.尝试从配置中找到一个TaskScheduler Bean
2.寻找ScheduledExecutorService Bean
前两步,如果找不到的话,就会以debug的方式抛出异常,分别是:
logger.debug("Could not find default TaskScheduler bean", ex);
logger.debug("Could not find default ScheduledExecutorService bean", ex);
所以,日志中打印出来的两个异常,根本不是什么错误信息,也不会影响定时器的使用,只不过是spring的自己打印的一些信息罢了,不过没搞明白,为什么非要用异常的方式打出来,估计是为了看这清晰点吧。也或者,这里面有一些重要的信息需要提示开发者。具体是什么原因,只能有机会进一步再去了解了。
【spring】Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'httpClient' available
项目启动时,spring容器中注册了restTemplate,但是未注册httpClient
【dubbo】No provider available for the service
<!-- dubbo从2.6.5升级至2.6.6时,需要显式引入此包 -->
<artifactId>netty-all</artifactId>
<version>4.1.31.Final</version><!--$NO-MVN-MAN-VER$-->
【dubbo】Caused by: java.lang.ClassNotFoundException: org.apache.curator.RetryPolicy
<!-- 当dubbo-spring-boot-starter从0.2.0升级至0.2.1.RELEASE及以后 ,需要补加此包-->
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
【zipkin】Caused by: java.lang.IllegalArgumentException: URI is not hierarchical
【zipkin】改用elasticsearch,依赖关系,就查不到了
通过对比发现,不使用elasticsearch5存储时,显示正常,但是通过es存储后,依赖显示不正常了
打印日志如下,RequestMappingHandlerMapping : Mapped to public byte[] zipkin2.server.internal.ZipkinQueryApiV2.getDependencies(long,java.lang.Long) throws java.io.IOException
【maven】[ERROR] java.lang.IllegalArgumentException: One of setGitDir or setWorkTree must be called.
【zipkin】出现访问正常,但是无法显示推送链路数据的情况
任何重启服务的方案都无效,重启centos系统后恢复正常,根本原因未知
Error executing query: Request processing failed; nested exception is java.lang.IllegalStateException: response for aggregation failed: {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [traceId] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"zipkin:span-2019-08-30","node":"2jl_umavR1uTzbMXw7Vkig","reason":{"type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [traceId] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."}}]},"status":400}
【zipkin】java.lang.RuntimeException: Fielddata is disabled on text fields by default. Set fielddata=true on [traceId] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.
zipkin2.11.1处理的数据,启动zipkin.2.16.1去读报错
一,spring组件重写构造方法,在构造方法中引用@value为null
由于spring实例化顺序为先执行构造方法,再注入成员变量,所以ing实例化顺取值为null
解决办法为:再写一个常量类,在常量类中引用@value,再在构造方法中引用常量类的变量即可。
二,调用spring组件时使用new对象,而不是@Autowired
spring mvc是spring的子容器,需要在两个配置文件中都导入配置文件
<context:property-placeholder location="classpath:jdbc.properties" ignore-unresolvable="true"/>
【DUBBO】qos-server can not bind localhost:22222
Qos=Quality of Service,qos是Dubbo的在线运维命令,可以对服务进行动态的配置、控制及查询,Dubboo2.5.8新版本重构了telnet(telnet是从Dubbo2.0.5开始支持的)模块,提供了新的telnet命令支持,新版本的telnet端口与dubbo协议的端口是不同的端口,默认为22222,可以通过配置文件dubbo.properties修改。telnet 模块现在同时支持 http 协议和 telnet 协议,方便各种情况的使用。
注意,从2.6.4/2.7.0开始,qosAcceptForeignIp默认配置改为false(拒绝远端主机发出的命令,只允许服务本机执行),如果qosAcceptForeignIp设置为true,有可能带来安全风险,请仔细评估后再打开。
https://blog.csdn.net/u012988901/article/details/84503672
【maven】java.lang.IllegalArgumentException: One of setGitDir or setWorkTree must be called.
【brave】java.lang.NoClassDefFoundError: org/apache/logging/log4j/ThreadContext
新引入的方法的brave.propagation.ThreadLocalCurrentTraceContext.create()导致的,
【spring】<context:component-scan base-package="controller.**" />
**匹配任意class文件和包,而*只能匹配包,因此无法扫描到包下的类,因此也就无法被Spring管理。
##brave-span#span#{"noop":true}
brave.sampler.Sampler初始化异常,导致样本全部丢弃,反应为"noop":true,跟设置了丢弃一个效果
如果您处于需要在运行时关闭跟踪的情况,请调用Tracing.setNoop(true)。这将把任何新的span变成“noop”span,并且丢弃所有数据直到Tracing.setNoop(false)被调用。
Description Resource Path Location Type web.xml is missing and <failOnMissingWebXml> is set to true pom.xml
【dubbox】Caused by: java.lang.ClassNotFoundException: javassist.ClassPath
使用Dubbo时,引入了javassist导致出现了ClassNotFoundException: javassist.ClassPath异常,因为此异常网上资料较少,特分享出来供大家脱坑:
message: Context initialization failed (o.s.web.context.ContextLoader:350) [localhost-startStop-1]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.wesd.hrhx.service.dubbo.DebtDubboService': Instantiation of bean failed; nested exception is java.lang.ExceptionInInitializerError.
从错误信息中可看出,错误来源于Spring注入DebtDubboService出错,我们继续往下找具体的原因:
Caused by: java.lang.NoClassDefFoundError: javassist/ClassPath
at java.lang.Class.forName0(Native Method)
仔细分析下Spring的Ioc原理即知:Spring使用类加载器加载类时,找不到javassist/ClassPath。
可是查看项目下发现依赖的包javassist-3.18.1-GA.jar,打开这些jar包,其中的javassist.ClassPath的确存在啊,于是我换了个版本javassist-3.18.2-GA.jar程序跑起来了。
其实就是因为JavassistCompile使用了类javassist.ClassPath。经过一点点的比较,最后发现 javassist-3.18.1-GA.jar这个包是有问题的,因为其MAINFEST.FM文件是打不开的,解压以后也报各种Class文件格式错误。
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
【spring】Rejected bean name 'contextAttributes': no URL paths identified
因暂未影响功能,暂时先忽略该DEBUG信息,将spring日志降级为INFO
logging.level.org.springframework.web=INFO
【dubbo】Caused by: java.lang.IllegalStateException: Failed to check the status of the service xxxxxx. No provider available for
<artifactId>netty-all</artifactId>
<version>4.1.31.Final</version>
【spring】Rejected bean name 'com.alibaba.dubbo.config.ApplicationConfig#0': no URL paths identified
java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.zipkin.kafka.topic' in value "${spring.zipkin.kafka.topic}"
【spring】org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: @Bean method 'initconfigTracingParam' must not be private or final; change the method's modifiers to continue
解决方案就在错误提示中 @Bean method 'initconfigTracingParam' must not be private or final;
【dubbo】java.lang.IllegalStateException: Cannot load configuration class: com.alibaba.boot.dubbo.autoconfigure.DubboAutoConfiguration
经排查,是springboot版本号与dubbo-spring-boot-starter版本不匹配导致的,
Dubbo Spring Boot Dubbo Spring Boot
【zipkin】org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalStateException: response for aggregation failed: {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata
o.s.w.s.h.BeanNameUrlHandlerMapping : Rejected bean name 'org.springframework.cloud.sleuth.instrument.messaging.TraceSpanMessagingAutoConfiguration': no URL paths identified
原因分析:自行定制编译的zipkin.jar包集成es7会有访问问题,官方推荐直接使用编译好的 jar 包
zipkin官方自己在githubReadme.md中也提到了,不支持集成es7:This uses Elasticsearch 5+ features, but is tested against Elasticsearch 6-7.x.
解决方案:通过docker部署,或者直接运行zipkin的jar包
【dubbo】com.alibaba.dubbo.remoting.RemotingException: Fail to decode request due to: RpcInvocation [methodName=getUserAddressList
1.传输的参数中是否包含了不能序列化的属性,例如ImmutableList、Joda DateTime等。
1.传输的参数中去除不能序列化的属性,使用可序列化参数代替。
【dubbo】spi机制,无法正常注入extensionFactory工厂方法中的对象
通过new工厂方法,测出问题所在:.encoding(Encoding.PROTO3) //这行代码异常导致无法注入成功
ExtensionFactory extensionFactory=new TracingExtensionFactory();
Tracing tracing =extensionFactory.getExtension(Tracing.class,"tracing");
报异常Exception in thread "main" java.lang.IllegalArgumentException: Encoder doesn't match Sender: JSON PROTO3
Sender sender = KafkaSender.newBuilder()
.bootstrapServers("10.1.240.213:9092")
// .encoding(Encoding.PROTO3) //这行代码异常导致无法注入成功
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.properties.source.ConfigurationPropertySources
at org.springframework.cloud.client.HostInfoEnvironmentPostProcessor.getFirstNonLoopbackHostInfo(HostInfoEnvironmentPostProcessor.java:46)
springcloud 与springboot版本兼容问题:springcloud2.x与springboot1.5.x不兼容,启动时,部分类找不到
SLF4J: Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path, preempting StackOverflowError.
使用maven构建项目时,如果项目中有log4j的依赖,在运行程序时可能会出现在同一个类中log4j-over-slf4j.jar和 slf4j-log4j12.jar冲突的问题
原因是:log4j-over-slf4j和slf4j-log4j12是跟Java日志系统相关的两个jar包,当它们同时出现在classpath下时,就可能会引起堆栈溢出异常。
解决办法:pom.xml文件中,在使用到的依赖包中添加<exclusion>标签将slf4j-log4j12.jar排除即可
org.apache.kafka.common.KafkaException: Socket server failed to bind to 10.1.240.213:9093: Cannot assign requested address.
wurstmeister/kafka:1.1.0改用为wurstmeister/kafka:2.11-1.1.0,可以解决这个问题
【kafka】usr/bin/start-kafka.sh: line 107: KAFKA_OPTS=-Djava.security.auth.login.config: bad substitution
port is deprecated. Please use KAFKA_ADVERTISED_LISTENERS instead.
WARN Client failed to SASL authenticate: javax.security.sasl.SaslException: DIGEST-MD5: digest response format violation. Mismatched response. (org.apache.zookeeper.server.ZooKeeperServer)
javax.security.sasl.SaslException: DIGEST-MD5: digest response format violation. Mismatched response.
【elasticsearch】Caused by: java.io.FileNotFoundException: /usr/share/elasticsearch/config/readonlyrest.yml (Is a directory)
【elasticsearch】Caused by: java.nio.file.AccessDeniedException: /usr/share/elasticsearch/data/nodes/0/node.lock
真正的原因是宿主机上的/data0/elasticsearch/data目录权限不足导致的!!!但是错误日志报的却是docker容器下的 /usr/share/elasticsearch/data/nodes目录
【dubbo】dubbo2.7.x与dubbo2.6.x TracingFilter差异很大,需要用各自的filter
【kibana】kibana启动日志报错信息 [illegal_argument_exception] mapper
elasticsearch5.x但是docker当时装的kibana7不匹配,
【kafka】kafka.common.KafkaException: Unknown offset schema version 3
WARN [Controller id=100, targetBrokerId=100] Connection to node 100 (/10.1.240.213:9082) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
WARN 27165 --- [pool-2-thread-1] o.a.k.c.NetworkClient : [Consumer clientId=consumer-1, groupId=zipkin] 1 partitions have leader brokers without a matching listener, including [zipkin-0]
kafka0.10版本,服务启动参数未配置listeners参数,需要手动配置才不会报错
例如用docker run 启动的话,添加如下参数:-e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 -e KAFKA_advertised_listeners=PLAINTEXT://10.1.240.213:9092
【kafka】Connection to node -1 could not be established. Broker may not be available.
但是由于基于docker部署,又更改了默认端口9092->映射为9093,导致listeners失效
【spring】java.lang.NoClassDefFoundError: org/springframework/boot/bind/RelaxedDataBinder
有相应的jar包,原因是在版本2.x之后删除了包.所以只要在之后的引用版本中换成2.x之后即可.
【kafka】Error while fetching metadata with correlation id 243 : {zipkin=LEADER_NOT_AVAILABLE}
因为Kafka的配置文件server.properties配置错了
没有配置listeners = PLAINTEXT://your.host.name:9092。在配置集群的时候,必须设置,不然以后的操作会报找不到leader的错误 ,修改后的代码如下。
【kafka】kafka in zipkin.autoconfigure.collector.kafka.ZipkinKafkaCollectorAutoConfiguration required a bean of type 'zipkin.collector.CollectorSampler' that could not be found.
zipkin-autoconfigure-collector-kafka版本匹配问题
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 null
中间有个微服务报异常,异常原因:@Reference注解,应该统一引用自apache旗下的dubbo类
【zipkin-spring】java.lang.IllegalArgumentException: Prometheus requires that all meters with the same name
#zipkin启动报错无法访问的解决方法 management.metrics.web.server.auto-time-requests=false
【dubbo】java.lang.NoClassDefFoundError: org/I0Itec/zkclient/IZkStateListener
dubbo缺少zkclient包,引入相应版本的包(如果引入包后报链接超时,逐渐降低zkclient版本继续尝试)
<artifactId>zkclient</artifactId>
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [org.springframework.cloud.sleuth.instrument.web.TraceWebServletAutoConfiguration]; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/web/servlet/handler/HandlerInterceptorAdapter.class] cannot be opened because it does not exist
Spring为我们提供了org.springframework.web.servlet.handler.HandlerInterceptorAdapter这个适配器,继承此类,可以非常方便的实现自己的拦截器。
【dubbo】Caused by: java.lang.ClassNotFoundException: io.netty.channel.EventLoopGroup
原因:缺少netty-all的jar包,在pom.xml中添加jar依赖即可,如下:
<!-- dubbo从2.6.5升级至2.6.6时,需要显式引入此包 -->
<artifactId>netty-all</artifactId>
<version>4.1.32.Final</version>
【dubbo】The bean 'dubboConfigConfiguration.Single', defined in null, could not be registered
Consider renaming one of the beans
or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
【dubbo】Caused by: java.lang.ClassNotFoundException: org.apache.curator.RetryPolicy
dubbo-spring-boot-starter版本从0.2.0升级至0.2.1后,缺少了curator依赖,需要自己手补
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
【zipkin-sleuth】spring.sleuth.sampler.percentage=1采样率不生效问题
spring.sleuth.sampler.probability=1(spring-cloud低版本配置的参数)
spring.sleuth.sampler.rate=1(高版本改成)
具体根据sleuth-core项目中的SamplerProperties.class来看支持哪个参数
【dubbo】com.alibaba.dubbo.rpc.RpcException: No provider available from registry 10.1.240.213:2181 for service com.alibaba.dubbo.monitor.MonitorService
不用监控前,可以暂时去掉application.properties中连接监控中心的配置参数
#dubbo.monitor.protocol=registry
【zipkin-brave】Caused by: java.lang.IllegalStateException: No such extension tracing for filter/com.alibaba.dubbo.rpc.Filter
(1)application.properties中引入tracing,sleuth等配置参数
(2)pom中引入brave-instrumentation-dubbo2.6-rpc包
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.alibaba.dubbo.config.ProtocolConfig#0': Initialization of bean failed;
【docker】WARNING: IPv4 forwarding is disabled. Networking will not work.
# vim /usr/lib/sysctl.d/00-system.conf
【spring】NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder
spring boot和spring cloud的关系不匹配导致
Spring Cloud | Spring Boot |
Finchley | 兼容Spring Boot 2.0.x,不兼容Spring Boot 1.5.x |
Dalston和Edgware | 兼容Spring Boot 1.5.x,不兼容Spring Boot 2.0.x |
Camden | 兼容Spring Boot 1.4.x,也兼容Spring Boot 1.5.x |
Brixton | 兼容Spring Boot 1.3.x,也兼容Spring Boot 1.4.x |
Angel | 兼容Spring Boot 1.2.x |
【dubbo】Caused by: java.lang.ClassNotFoundException: com.alibaba.spring.util.PropertySourcesUtils
<groupId>com.alibaba.spring</groupId>
<artifactId>spring-context-support</artifactId>
Caused by: java.lang.ClassNotFoundException: io.netty.channel.EventLoopGroup
com.linecorp.armeria.client.endpoint.EndpointGroupException: failed to receive DNS records
Suppressed: java.net.UnknownHostException: failed to resolve 'elasticsearch' after 2 queries
docker中启动的elasticsearch服务没有成功,根本原因是内存不够大
elasticsearch | [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
问题翻译过来就是:elasticsearch用户拥有的max_map_count太小,至少需要262144
sysctl -a|grep vm.max_map_count
#>vim /etc/sysctl.conf文件最后添加一行
【docker】运行docker-compose 命令报错:-bash: docker-compose: command not found
Docker-Compose是一个部署多个容器的简单但是非常必要的工具.
安装Docker-Compose之前,请先安装 python-pip
【docker】Docker 启动报错 Error starting daemon: SELinux is not supported with the overlay2 ...alse)
设置OPTIONS='--selinux-enabled=false
【docker】docker安装异常,Failed connect to download.docker.com:443; Operation now in progress
【centos7】解决ifconfig command not found
2) 安装Docker-Compose:
pip install docker-compose
检查是是否成功:
docker-compose -version