系统环境
- OS version:CentOS Linux release 7.7.1908
- JDK version:1.8.0_181
- 已经编译好的wedatasphere-exchangis-0.5.0.RELEASE
故障现象
现象1:
[root@master02 bin]# sh exchangis-service.sh start
2021-02-08 14:56:56.336 [INFO] (52057) load environment variables
2021-02-08 14:56:56.701 [INFO] (52057) /usr/java/jdk1.8.0_181-cloudera/bin/java
2021-02-08 14:56:56.704 [INFO] (52057) Waiting EXCHANGIS-SERVICE to start complete ...
2021-02-08 14:56:56.964 [INFO] (52057) EXCHANGIS-SERVICE start success
[root@master02 bin]# jps|grep -i ServiceApplication
[root@master02 bin]#
使用启动脚本启动,显示启动成功,但很快进程就退出,无任何错误显示,各种调整配置均不能成功启动。
研究启动脚本exchangis-service.sh后,摘取启动的java命令,触发现象2
现象2:
执行如下命令:
java -Xms2g -Xmx2g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -Dserver.port=9504 -Ddata.path=/data2/app/wedatasphere-exchangis-0.5.0.RELEASE/modules/exchangis-service/data -XX:HeapDumpPath=/data2/app/wedatasphere-exchangis-0.5.0.RELEASE/modules/exchangis-service/logs -Dlog.path=/data2/app/wedatasphere-exchangis-0.5.0.RELEASE/modules/exchangis-service/logs -Dlogging.config=/data2/app/wedatasphere-exchangis-0.5.0.RELEASE/modules/exchangis-service/conf/logback.xml -classpath /data2/app/wedatasphere-exchangis-0.5.0.RELEASE/modules/exchangis-service/lib/*:/data2/app/wedatasphere-exchangis-0.5.0.RELEASE/modules/exchangis-service/conf:. com.webank.wedatasphere.exchangis.ServiceApplication
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/data2/app/wedatasphere-exchangis-0.5.0.RELEASE/modules/exchangis-service/lib/log4j-slf4j-impl
-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/data2/app/wedatasphere-exchangis-0.5.0.RELEASE/modules/exchangis-service/lib/logback-classic-
1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
**Exception in thread "main" java.lang.StackOverflowError**
at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:936)
at org.apache.logging.log4j.spi.LoggerRegistry.getOrCreateInnerMap(LoggerRegistry.java:140)
at org.apache.logging.log4j.spi.LoggerRegistry.hasLogger(LoggerRegistry.java:154)
at org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:38)
at org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:37)
at org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:29)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:52)
at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281)
at org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
at org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:37)
at org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:29)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:52)
at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281)
at org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
at org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:37)
at org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:29)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:52)
at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
综合以上现象,初步怀疑是log4j和logback有冲突导致的循环依赖
解决方案
step1 :mv exchangis-service/lib下的log4j包至上一层级目录
mv log4j*.jar ../
step2: 重新执行启动脚本
[root@master02 bin]# ./exchangis-service.sh start
2021-02-08 15:27:59.776 [INFO] (62814) load environment variables
2021-02-08 15:28:00.137 [INFO] (62814) /usr/java/jdk1.8.0_181-cloudera/bin/java
2021-02-08 15:28:00.140 [INFO] (62814) Waiting EXCHANGIS-SERVICE to start complete ...
2021-02-08 15:28:00.395 [INFO] (62814) EXCHANGIS-SERVICE start success
[root@master02 bin]# jps|grep -i ServiceApplication
62988 ServiceApplication
总结
log4j相关包导致了循环依赖问题,最终触发StackOverflowError