Java analysis using Java 10, and overall java support

scanner
java

(Ed Hillmann) #1

Hi. I have had a Maven Project using the sonar maven plugin for a while now, interacting with a SonarQube server. Up until know, I have been using Java 8 when building and performing static analysis.

However, when I change to use OpenJDK 10 (10.0.2), the sonar:sonar goal fails. The exception is

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.717 s
[INFO] Finished at: 2018-09-03T10:36:03+10:00
[INFO] Final Memory: 62M/214M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar (default-cli) on project minestar-core: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar failed: A required class was missing while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar: javax/xml/bind/ValidationEventHandler
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.sonarsource.scanner.maven:sonar-maven-plugin:3.2
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/hillmep/.m2/repository/org/sonarsource/scanner/maven/sonar-maven-plugin/3.2/sonar-maven-plugin-3.2.jar
[ERROR] urls[1] = file:/C:/Users/hillmep/.m2/repository/javax/xml/bind/jaxb-api/2.3.0/jaxb-api-2.3.0.jar
[ERROR] urls[2] = file:/C:/Users/hillmep/.m2/repository/com/sun/xml/bind/jaxb-impl/2.3.0/jaxb-impl-2.3.0.jar
[ERROR] urls[3] = file:/C:/Users/hillmep/.m2/repository/com/sun/xml/bind/jaxb-core/2.3.0/jaxb-core-2.3.0.jar
[ERROR] urls[4] = file:/C:/Users/hillmep/.m2/repository/org/apache/maven/shared/maven-dependency-tree/2.2/maven-dependency-tree-2.2.jar
[ERROR] urls[5] = file:/C:/Users/hillmep/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
[ERROR] urls[6] = file:/C:/Users/hillmep/.m2/repository/org/eclipse/aether/aether-util/0.9.0.M2/aether-util-0.9.0.M2.jar
[ERROR] urls[7] = file:/C:/Users/hillmep/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.4/plexus-sec-dispatcher-1.4.jar
[ERROR] urls[8] = file:/C:/Users/hillmep/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[9] = file:/C:/Users/hillmep/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.22/plexus-utils-3.0.22.jar
[ERROR] urls[10] = file:/C:/Users/hillmep/.m2/repository/org/sonarsource/scanner/api/sonar-scanner-api/2.8/sonar-scanner-api-2.8.jar
[ERROR] urls[11] = file:/C:/Users/hillmep/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar
[ERROR] urls[12] = file:/C:/Users/hillmep/.m2/repository/com/google/code/findbugs/jsr305/2.0.3/jsr305-2.0.3.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
[ERROR] 
[ERROR] -----------------------------------------------------
[ERROR] : javax.xml.bind.ValidationEventHandler
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar (default-cli) on project minestar-core: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar failed: A required class was missing while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar: javax/xml/bind/ValidationEventHandler
-----------------------------------------------------
realm =    plugin>org.sonarsource.scanner.maven:sonar-maven-plugin:3.2
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/C:/Users/hillmep/.m2/repository/org/sonarsource/scanner/maven/sonar-maven-plugin/3.2/sonar-maven-plugin-3.2.jar
urls[1] = file:/C:/Users/hillmep/.m2/repository/javax/xml/bind/jaxb-api/2.3.0/jaxb-api-2.3.0.jar
urls[2] = file:/C:/Users/hillmep/.m2/repository/com/sun/xml/bind/jaxb-impl/2.3.0/jaxb-impl-2.3.0.jar
urls[3] = file:/C:/Users/hillmep/.m2/repository/com/sun/xml/bind/jaxb-core/2.3.0/jaxb-core-2.3.0.jar
urls[4] = file:/C:/Users/hillmep/.m2/repository/org/apache/maven/shared/maven-dependency-tree/2.2/maven-dependency-tree-2.2.jar
urls[5] = file:/C:/Users/hillmep/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
urls[6] = file:/C:/Users/hillmep/.m2/repository/org/eclipse/aether/aether-util/0.9.0.M2/aether-util-0.9.0.M2.jar
urls[7] = file:/C:/Users/hillmep/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.4/plexus-sec-dispatcher-1.4.jar
urls[8] = file:/C:/Users/hillmep/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
urls[9] = file:/C:/Users/hillmep/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.22/plexus-utils-3.0.22.jar
urls[10] = file:/C:/Users/hillmep/.m2/repository/org/sonarsource/scanner/api/sonar-scanner-api/2.8/sonar-scanner-api-2.8.jar
urls[11] = file:/C:/Users/hillmep/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar
urls[12] = file:/C:/Users/hillmep/.m2/repository/com/google/code/findbugs/jsr305/2.0.3/jsr305-2.0.3.jar
Number of foreign imports: 1
import: Entry[import  from realm ClassRealm[maven.api, parent: null]]

-----------------------------------------------------

	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	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: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar failed: A required class was missing while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar: javax/xml/bind/ValidationEventHandler
-----------------------------------------------------
realm =    plugin>org.sonarsource.scanner.maven:sonar-maven-plugin:3.2
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/C:/Users/hillmep/.m2/repository/org/sonarsource/scanner/maven/sonar-maven-plugin/3.2/sonar-maven-plugin-3.2.jar
urls[1] = file:/C:/Users/hillmep/.m2/repository/javax/xml/bind/jaxb-api/2.3.0/jaxb-api-2.3.0.jar
urls[2] = file:/C:/Users/hillmep/.m2/repository/com/sun/xml/bind/jaxb-impl/2.3.0/jaxb-impl-2.3.0.jar
urls[3] = file:/C:/Users/hillmep/.m2/repository/com/sun/xml/bind/jaxb-core/2.3.0/jaxb-core-2.3.0.jar
urls[4] = file:/C:/Users/hillmep/.m2/repository/org/apache/maven/shared/maven-dependency-tree/2.2/maven-dependency-tree-2.2.jar
urls[5] = file:/C:/Users/hillmep/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
urls[6] = file:/C:/Users/hillmep/.m2/repository/org/eclipse/aether/aether-util/0.9.0.M2/aether-util-0.9.0.M2.jar
urls[7] = file:/C:/Users/hillmep/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.4/plexus-sec-dispatcher-1.4.jar
urls[8] = file:/C:/Users/hillmep/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
urls[9] = file:/C:/Users/hillmep/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.22/plexus-utils-3.0.22.jar
urls[10] = file:/C:/Users/hillmep/.m2/repository/org/sonarsource/scanner/api/sonar-scanner-api/2.8/sonar-scanner-api-2.8.jar
urls[11] = file:/C:/Users/hillmep/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar
urls[12] = file:/C:/Users/hillmep/.m2/repository/com/google/code/findbugs/jsr305/2.0.3/jsr305-2.0.3.jar
Number of foreign imports: 1
import: Entry[import  from realm ClassRealm[maven.api, parent: null]]

-----------------------------------------------------

	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:168)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
	... 20 more
Caused by: org.apache.maven.plugin.PluginContainerException: A required class was missing while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar: javax/xml/bind/ValidationEventHandler
-----------------------------------------------------
realm =    plugin>org.sonarsource.scanner.maven:sonar-maven-plugin:3.2
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/C:/Users/hillmep/.m2/repository/org/sonarsource/scanner/maven/sonar-maven-plugin/3.2/sonar-maven-plugin-3.2.jar
urls[1] = file:/C:/Users/hillmep/.m2/repository/javax/xml/bind/jaxb-api/2.3.0/jaxb-api-2.3.0.jar
urls[2] = file:/C:/Users/hillmep/.m2/repository/com/sun/xml/bind/jaxb-impl/2.3.0/jaxb-impl-2.3.0.jar
urls[3] = file:/C:/Users/hillmep/.m2/repository/com/sun/xml/bind/jaxb-core/2.3.0/jaxb-core-2.3.0.jar
urls[4] = file:/C:/Users/hillmep/.m2/repository/org/apache/maven/shared/maven-dependency-tree/2.2/maven-dependency-tree-2.2.jar
urls[5] = file:/C:/Users/hillmep/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
urls[6] = file:/C:/Users/hillmep/.m2/repository/org/eclipse/aether/aether-util/0.9.0.M2/aether-util-0.9.0.M2.jar
urls[7] = file:/C:/Users/hillmep/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.4/plexus-sec-dispatcher-1.4.jar
urls[8] = file:/C:/Users/hillmep/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
urls[9] = file:/C:/Users/hillmep/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.22/plexus-utils-3.0.22.jar
urls[10] = file:/C:/Users/hillmep/.m2/repository/org/sonarsource/scanner/api/sonar-scanner-api/2.8/sonar-scanner-api-2.8.jar
urls[11] = file:/C:/Users/hillmep/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar
urls[12] = file:/C:/Users/hillmep/.m2/repository/com/google/code/findbugs/jsr305/2.0.3/jsr305-2.0.3.jar
Number of foreign imports: 1
import: Entry[import  from realm ClassRealm[maven.api, parent: null]]

-----------------------------------------------------

	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:166)
	... 21 more
Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/ValidationEventHandler
	at com.hello2morrow.sonargraph.integration.access.controller.MetaDataControllerImpl.internLoadExportMetaData(MetaDataControllerImpl.java:104)
	at com.hello2morrow.sonargraph.integration.access.controller.MetaDataControllerImpl.loadExportMetaData(MetaDataControllerImpl.java:93)
	at com.hello2morrow.sonargraph.integration.sonarqube.api.SonargraphRulesRepository.loadDefaultConfigurationDataFromPlugin(SonargraphRulesRepository.java:291)
	at com.hello2morrow.sonargraph.integration.sonarqube.api.SonargraphRulesRepository.loadMetaDataForConfiguration(SonargraphRulesRepository.java:272)
	at com.hello2morrow.sonargraph.integration.sonarqube.api.SonargraphRulesRepository.getMetrics(SonargraphRulesRepository.java:94)
	at org.sonar.scanner.bootstrap.MetricProvider.provide(MetricProvider.java:49)
	at org.sonar.scanner.bootstrap.MetricProvider.provide(MetricProvider.java:31)
	at org.sonar.scanner.bootstrap.ExtensionInstaller.install(ExtensionInstaller.java:61)
	at org.sonar.scanner.scan.ProjectScanContainer.addBatchExtensions(ProjectScanContainer.java:234)
	at org.sonar.scanner.scan.ProjectScanContainer.doBeforeStart(ProjectScanContainer.java:117)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:133)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
	at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:48)
	at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:84)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
	at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:121)
	at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.java:116)
	at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:111)
	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:62)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
	at com.sun.proxy.$Proxy23.execute(Unknown Source)
	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:233)
	at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
	at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute(ScannerBootstrapper.java:78)
	at org.sonarsource.scanner.maven.SonarQubeMojo.execute(SonarQubeMojo.java:122)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
	... 21 more
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.ValidationEventHandler
	at org.sonar.classloader.ParentFirstStrategy.loadClass(ParentFirstStrategy.java:39)
	at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:87)
	at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:76)
	... 52 more

This looks like a reflection that Java 10 is no longer providing JavaEE modules by default. I have tried different approaches to allow the plugin to find these classes

  • I added compilerArgs to the compiler plugin to add the javax.xml.bind module
  • I defined direct dependencies to the project itself
  • I defined direct dependencies to the sonar-maven-plugin

None of the above helped. The plugin seems unable to find the jaxb classes.

I am using

  • Open JDK 10.0.2
  • Maven 10.0.2
  • sonar-maven-plugin 3.2
  • SonarJava 5.7.0.15470
  • SonarQube 6.7.2.37468

I have seen a similar query around the Gradle plugin. Is this a similar scenario?

I’m not sure if I haven’t set up my plugin correctly, or I need to upgrade my plugin and/or SonarQube. Thank you for any information in advance.

Ed


(Nicolas Bontoux) #2

Hi Ed,

Two main thoughts on this.

  • First up the issue occurs in this 3rd-party plugin (com.hello2morrow.sonargraph), so you might want to contact the plugin maintainer to know if they have any such known issue around Java 10

  • secondly you should be aware that SonarQube itself does not fully support Java 10. The requirements do not only apply to the server-side, they also apply to scanner execution and code analysis.

Note that this doesn’t prevent you from moving to Java 10 for your build. You can then use a different Java version for analysing with SonarQube.


(Ed Hillmann) #3

Thanks for the help, @NicoB. For the immediate term, I have continued using Java 8 for our analysis build. Certainly for the short term, this will be sufficient as we’re not using any Java 10 language features that would require a java 10 compiler.

I’ll see if I can get any information from the plugin maintainer and, should it be fixed, hope this is the only issue.

I’ll see if I can find a roadmap for when Java 10 will be supported. For me, the priority is less around the version of Java used on the server-side and more about the environments performing the analysis. Probably, for this specific issue, it’s really when Java 9 will be supported. But it will be useful for our team when we need to make decisions around changing major versions if we have a better understanding of the roadmaps for our various tools.

Thanks again,
Ed


(Nicolas Bontoux) #4

Thanks for the feedback Ed.

Makes sense. What I can tell is that here @ SonarSource the teams are looking into the nitty-gritty details of what it would take to support those latest versions of Java (some of the JDK changes are substantial), and also determine a strategy that makes sense on the long run (given the evolving Java lifecycle). No firm update at this stage, but a clearer plan should take shape over the next couple of months.


(Ed Hillmann) #5

That too makes sense. We’ve just done our own upgrade, which wasn’t too bad in the scheme of things but was more labor-intensive that previous Java releases. So I can empathize with the process there. As you stated, because the updates will be more frequent, having that strategy will be important. I’ll keep checking back when I remember :smile:


(Ed Hillmann) #6

So, just as an update, the Sonargraph integration plugin doesn’t support Java 9/10 and won’t until SonarQube does. I hope we’re not getting into chicken/egg territory. Hopefully, there will be something soon(ish) around support for this