" java.lang.NoClassDefFoundError: com/ctc/wstx/util/StringUtil

While running sonar:sonar from maven to import custom generic report sonar fails with the following exception, anything missing or needs to be done in order to import custom generic reports?

  • When I run mvn sonar:sonar all works fine.
  • Even when I use the sample documentation report I got same exception

Thanks in advance

Exception in thread "main" java.lang.NoClassDefFoundError: com/ctc/wstx/util/StringUtil
	at com.ctc.wstx.exc.WstxException.getMessage(WstxException.java:82)
	at org.apache.maven.exception.DefaultExceptionHandler.getMessage(DefaultExceptionHandler.java:274)
	at org.apache.maven.exception.DefaultExceptionHandler.handle(DefaultExceptionHandler.java:124)
	at org.apache.maven.exception.DefaultExceptionHandler.handleException(DefaultExceptionHandler.java:96)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:972)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:192)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: java.lang.ClassNotFoundException: com.ctc.wstx.util.StringUtil
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
	at org.sonarsource.scanner.api.internal.IsolatedClassloader.loadClass(IsolatedClassloader.java:82)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 15 more

SonarQube version: 8.9.0

Generic report content :
{
“issues”: [
{
“engineId”: “abc-maven”,
“ruleId”: “my-check”,
“severity”: “MINOR”,
“type”: “CODE_SMELL”,
“primaryLocation”: {
“message”: “Plugin ‘spring-boot-maven-plugin:org.springframework.boot’ must be skipped”,
“filePath”: “myartifactGroupid:myartifactid:21.11.0-SNAPSHOT”
}
}
]
}

Hi,

Welcome to the community!

What version of the Scanner for Maven are you using? Do you have an old version pinned in your pom?

 
Ann

Thank you for your answer.

In maven log I can see :
[INFO] — sonar-maven-plugin:3.9.0.2155:sonar (default-cli)
[INFO] SonarQube version: 8.9.0

my sonar version is also 8.9.
Running this from command line, I’m not providing sonar version my pom, I added as mentioned in the documentation the sonar pluginGroup entry in the settings.xml

I’m trying using maven 3.5.0 and 3.6.0

Hi,

So it looks like the scanner and SonarQube itself are both up to date. What version of Java are you running analysis with? In fact, can you just provide the whole analysis log?

 
Ann

I’m running with JDK 1.8.0_221

INFO Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.***.bl:child-domain:jap-domain:21.11.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.springframework.boot:spring-boot-maven-plugin is missing. @ com.***.bl:child-domain:[unknown-version], C:\****\parent\child-domain\pom.xml, line 615, column 13
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
...
INFO ------------------------------------------------------------------------
INFO Building com.***.bl::parent 21.11.0-SNAPSHOT
INFO ------------------------------------------------------------------------
[WARNING] The POM for com.***.***.poms:wls-deps:pom:8.0.0.7 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
INFO 
INFO --- sonar-maven-plugin:3.9.0.2155:sonar (default-cli) @ parent ---
INFO User cache: C:\Users\me\.sonar\cache
INFO SonarQube version: 8.9.0
INFO Default locale: "en_US", source code encoding: "UTF-8"
[WARNING] SonarScanner will require Java 11 to run, starting in SonarQube 9.x
INFO Load global settings
INFO Load global settings (done) | time=288ms
...
INFO Load plugins index (done) | time=153ms
INFO Load/download plugins (done) | time=486ms
INFO Loaded core extensions: developer-scanner
...
INFO Project configuration:
INFO Indexing files of module 'com.***.bl::child-config'
INFO   Base dir: C:\****\parent\child-config
INFO   Source paths: pom.xml
INFO Indexing files of module 'com.***.bl::child-domain'
INFO   Base dir: C:\****\parent\child-domain
INFO   Source paths: pom.xml
INFO Indexing files of module 'com.***.bl::parent'
INFO   Base dir: C:\****\parent
INFO   Source paths: pom.xml
INFO 3 files indexed
INFO 0 files ignored because of scm ignore settings
INFO Quality profile for xml: Sonar way
...
INFO ------------- Run sensors on module com.***.bl::parent
INFO JavaScript/TypeScript frontend is enabled
INFO Sensor CSS Rules [cssfamily]
INFO No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.
INFO Sensor CSS Rules [cssfamily] (done) | time=0ms
...
INFO Sensor C# Properties [csharp] (done) | time=0ms
...
INFO Sensor ThymeLeaf template sensor [securityjavafrontend]
INFO Sensor ThymeLeaf template sensor [securityjavafrontend] (done) | time=1ms
INFO Sensor Generic Test Executions Report
INFO Parsing C:\****\parent\Target\dependencies-checks.json
INFO ------------------------------------------------------------------------
INFO Reactor Summary:
INFO 
INFO com.***.bl::parent ...................... FAILURE [ 34.075 s]
...
---------------------------------------------------
Exception in thread "main" java.lang.NoClassDefFoundError: com/ctc/wstx/util/StringUtil
	at com.ctc.wstx.exc.WstxException.getMessage(WstxException.java:82)
	at org.apache.maven.exception.DefaultExceptionHandler.getMessage(DefaultExceptionHandler.java:271)
	at org.apache.maven.exception.DefaultExceptionHandler.handle(DefaultExceptionHandler.java:121)
	at org.apache.maven.exception.DefaultExceptionHandler.handleException(DefaultExceptionHandler.java:93)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:1009)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: java.lang.ClassNotFoundException: com.ctc.wstx.util.StringUtil
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
	at org.sonarsource.scanner.api.internal.IsolatedClassloader.loadClass(IsolatedClassloader.java:82)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 15 more

Hi,

You’re going to need to run analysis with Java 11. You can still build with (or to) Java 8 if you like, but you need to analyze with Java 11. (The docs.)

 
HTH,
Ann

Thank you very much Anna for your feedback. I think using Java 11 is not an option in my case, I will mark this solution is solved as I see reference to java 11 in the sonar log even though it is expected starting sonar 9. As a work around I will wrap my report in an PMD or checkstyle report and import it as such.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.