Sonar-scanner-cli dose not work on Windows Svr 2022 Std!

Hello team! I encountered a question with sonar-scanner on Windows Svr 2022 Std, the detail is:

System: Windows Svr 2022 Std

java Env:

openjdk 17.0.0.1 2024-07-02

OpenJDK Runtime Environment (build 17.0.0.1+2-3)

OpenJDK 64-Bit Server VM (build 17.0.0.1+2-3, mixed mode, sharing)

sonnar-scanner(I tested both):

sonar-scanner-cli-6.1.0.4477.zip &&

sonar-scanner-cli-6.1.0.4477-windows-x64.zip

Error:
SLF4J(E): A service provider failed to instantiate:
org.slf4j.spi.SLF4JServiceProvider: Error accessing configuration file
SLF4J(W): No SLF4J providers were found.
SLF4J(W): Defaulting to no-operation (NOP) logger implementation
SLF4J(W): See https://www.slf4j.org/codes.html#noProviders for further details.
Exception in thread "main" java.lang.ClassCastException: class org.slf4j.helpers.NOPLogger cannot be cast to class ch.qos.logback.classic.Logger (org.slf4j.helpers.NOPLogger and ch.qos.logback.classic.Logger are in unnamed module of loader 'app')
    at org.sonarsource.scanner.cli.Cli.processNextArg(Cli.java:92)
    at org.sonarsource.scanner.cli.Cli.parse(Cli.java:70)
    at org.sonarsource.scanner.cli.Main.main(Main.java:61)

Hi,

Welcome to the community!

I’ll be honest & say I’ve never seen this error before.

You got this when you tried to invoke the scanner? And if so, can we have the full log, starting from the command itself?

Also, can you share where you installed the scanner and whether you added it to %PATH%?

 
Thx,
Ann

Hi team,

The full command invoke scanner is(start from my CI bat):
sonar-scanner.bat -Dsonar.projectKey=win-ci-demo -Dsonar.projectBaseDir=%ROOT_DIR% -Dsonar.sources=“%SRC_DIR%” -Dsonar.cxx.cppcheck.reportPaths=./build/cppcheck-result.xml -Dsonar.cxx.cobertura.reportPaths=./build/coverage-result.xml -X

scanner path is:

Error Info:

Hi,

Can we have the full text of the log, copy/pasted into a post, starting from the analysis command, please?

 
Thx,
Ann

1 Like

Hi,
Below is the error scene when I manually execute my post.bat script :
post.bat.txt (1.2 KB)

I have an extra clue: I was using Windows Svr 2022 Std in Korean, and then changed the language to Simplified Chinese

PS C:\Users\ncl_intdev!\actions-runner\_work\gitaction-ci-demo\gitaction-ci-demo> .\scripts\win32\post.bat
ROOT_DIR directory: C:\Users\ncl_intdev!\actions-runner\_work\gitaction-ci-demo\gitaction-ci-demo
 SCRIPT_DIR directory is: C:\Users\ncl_intdev!\actions-runner\_work\gitaction-ci-demo\gitaction-ci-demo\scripts\win32\
 ROOT_DIR directory is: C:\Users\ncl_intdev!\actions-runner\_work\gitaction-ci-demo\gitaction-ci-demo
 BUILD_DIR directory is: C:\Users\ncl_intdev!\actions-runner\_work\gitaction-ci-demo\gitaction-ci-demo\build
 SRC_DIR directory is: C:\Users\ncl_intdev!\actions-runner\_work\gitaction-ci-demo\gitaction-ci-demo\src
Checking C:\Users\ncl_intdev!\actions-runner\_work\gitaction-ci-demo\gitaction-ci-demo\src\gcovr\gcovr-test.cpp ...
[info] Start Program:
Path:"C:\\Users\\ncl_intdev!\\actions-runner\\_work\\gitaction-ci-demo\\gitaction-ci-demo\\bin\\Debug\\gcovr-test.exe"
Arguments:
Working directory: not set.
Modules: Selected: C:\Users\ncl_intdev!\actions-runner\_work\gitaction-ci-demo\gitaction-ci-demo\bin\Debug\gcovr-test.exe Excluded:
Sources: Selected: C:\Users\ncl_intdev!\actions-runner\_work\gitaction-ci-demo\gitaction-ci-demo\src Excluded:
Log Level: Normal
Cover Children: 0
Aggregate by file: 1
Continue after C++ exception: 0
Optimized build support: 0
Export: cobertura coverage-result.xml
Input coverage:
Unified diff:
Excluded line regular expressions:
Substitute pdb source paths:
[info] Module: C:\Users\ncl_intdev!\actions-runner\_work\gitaction-ci-demo\gitaction-ci-demo\bin\Debug\gcovr-test.exe is selected because it matches selected pattern: C:\Users\ncl_intdev!\actions-runner\_work\gitaction-ci-demo\gitaction-ci-demo\bin\Debug\gcovr-test.exe
just a gcovr test!
[info] ----------------------------------------------------
[info] Cobertura report generated: coverage-result.xml
[info] ----------------------------------------------------
[info] The code coverage report is not what you expect? See the FAQ https://github.com/OpenCppCoverage/OpenCppCoverage/wiki/FAQ.
SLF4J(E): A service provider failed to instantiate:
org.slf4j.spi.SLF4JServiceProvider: Error accessing configuration file
SLF4J(W): No SLF4J providers were found.
SLF4J(W): Defaulting to no-operation (NOP) logger implementation
SLF4J(W): See https://www.slf4j.org/codes.html#noProviders for further details.
Exception in thread "main" java.lang.ClassCastException: class org.slf4j.helpers.NOPLogger cannot be cast to class ch.qos.logback.classic.Logger (org.slf4j.helpers.NOPLogger and ch.qos.logback.classic.Logger are in unnamed module of loader 'app')
        at org.sonarsource.scanner.cli.Cli.processNextArg(Cli.java:92)
        at org.sonarsource.scanner.cli.Cli.parse(Cli.java:70)
        at org.sonarsource.scanner.cli.Main.main(Main.java:61)
PS C:\Users\ncl_intdev!\actions-runner\_work\gitaction-ci-demo\gitaction-ci-demo>

Hi,

All I see here is the command to execute your script, from which analysis is presumably kicked off.

The problem I’m seeing is that while the stacktrace includes org.sonarsource.scanner.cli..., I don’t see anything in your log before that that relates directly to the scanner or indicates in any way that the scanner has actually been invoked.

Can you either modify your script to echo out the commands before it runs them or set the script aside and run each command manually from the command line. And whichever option you choose, provide the text of the entire log file?

Because right now, I’ve got nothing to go on.

 
Thx,
Ann

P.S. I’m told that Set-PSDebug (Microsoft.PowerShell.Core) - PowerShell | Microsoft Learn might help.

Hello,
If I excute command in commandline,the output is follow:

PS C:\Users\ncl_intdev!\actions-runner\_work\gitaction-ci-demo\gitaction-ci-demo\build> sonar-scanner.bat  -Dsonar.projectKey=win-ci-demo -Dsonar.projectBaseDir="C:\Users\ncl_intdev!\actions-runner\_work\gitaction-ci-demo\gitaction-ci-demo" -Dsonar.sources="C:\Users\ncl_intdev!\actions-runner\_work\gitaction-ci-demo\gitaction-ci-demo\src" -Dsonar.cxx.cppcheck.reportPaths=./build/cppcheck-result.xml -Dsonar.cxx.cobertura.reportPaths=./build/coverage-result.xml -X
DEBUG:    1+  >>>> sonar-scanner.bat  -Dsonar.projectKey=win-ci-demo
-Dsonar.projectBaseDir="C:\Users\ncl_intdev!\actions-runner\_work\gitaction-ci-demo\gitaction-ci-demo"
-Dsonar.sources="C:\Users\ncl_intdev!\actions-runner\_work\gitaction-ci-demo\gitaction-ci-demo\src"
-Dsonar.cxx.cppcheck.reportPaths=./build/cppcheck-result.xml
-Dsonar.cxx.cobertura.reportPaths=./build/coverage-result.xml -X
SLF4J(E): A service provider failed to instantiate:
org.slf4j.spi.SLF4JServiceProvider: Error accessing configuration file
SLF4J(W): No SLF4J providers were found.
SLF4J(W): Defaulting to no-operation (NOP) logger implementation
SLF4J(W): See https://www.slf4j.org/codes.html#noProviders for further details.

usage: sonar-scanner [options]

Options:
 -D,--define <arg>     Define property
 -h,--help             Display help information
 -v,--version          Display version information
 -X,--debug            Produce execution debug output

The previously mentioned “Exception in thread “main” java.lang.ClassCastException:” error message was obtained by executing bat through Github-Actions. I don’t know the difference, but I can be sure that by setting different Github-Actions runners, it can be executed normally on the win10 system and get the expected results without exception.

Hi,

It looks like you’re using the community Cxx plugin. Can you remove that & see if you still get this error?

Would it be possible also to try this with an English setting?

 
Thx,
Ann