sonar扫描 ERROR: Unable to create symbol table for :..
先贴报错:
ERROR: Unable to create symbol table for : /home/kaizhidev/.jenkins/workspace/huiche_backend/ace-modules/zvic-search-service/src/main/java/com/kaizhi/zvic/search/model/vo/Analysis24hCountOverviewVO.java
java.lang.IllegalArgumentException: null
at org.objectweb.asm.ClassReader.<init>(ClassReader.java:185)
at org.objectweb.asm.ClassReader.<init>(ClassReader.java:168)
at org.sonar.java.resolve.BytecodeCompleter.loadClass(BytecodeCompleter.java:236)
at org.sonar.java.resolve.Symbols.<init>(Symbols.java:176)
at org.sonar.java.resolve.SemanticModel.createFor(SemanticModel.java:56)
.....
原因: 之前的sonar-scanner不支持jdk1.8
从日志中可以看到Unsupported class file major version 55,这说明是jdk版本的不一致所导致的。
注意,version 55 其实指的就是 jdk 1.11版本。
而我通过执行命令sonar-scanner -v输出如下:
[root@node1 app]# sonar-scanner -v
INFO: Scanner configuration file: /usr/local/sonar-scanner/conf/sonar-scanner.properties
INFO: Project root configuration file: /usr/local/workspace/simple-java-maven-app/sonar-project.properties
INFO: SonarQube Scanner 4.0.0.1744
INFO: Java 11.0.3 AdoptOpenJDK (64-bit)
INFO: Linux 3.10.0-327.el7.x86_64 amd64
由此可以得知是 Sonar-Scanner的版本错误,导致其支持jdk 1.11版本,从而与我系统的jdk 1.8版本产生了冲突。
解决方案一: 升级jdk 至11
可以参考 https://blog.csdn.net/weixin_44003789/article/details/101463191
解决方案二: 下载低版本的 sonar runner
例如:sonar-scanner-2.8.zip
下载地址 https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-2.8.zip