SonarQube support for OpenJDK 11

I have sent DM to you.Pls take a look and let me know.

Thanks,
Anil

Finally Its issue with Databinding with sonarcobe 7.9 version.Just integrated on some databinding sample code and seeing same issue JAXB Exception.
(FYI…With sample code which does not have data binding it works fine)

Unable to attache zip file.Can you pls let me know how to share sample code to reproduce the issue.

Thanks,
Anil

Hi Anil,

Based on the samples you sent me, I was able to reproduce the issue. I don’t see any relation with the sonarqube gradle plugin, and the error still happens after removing it from the build.

The android gradle plugin exposes an annotation processor that uses JAXB, and probably it doesn’t package it. This is not compatible with Java 11.

The error happens when gradle attempts to load JAXBException imported in this class: https://android.googlesource.com/platform/frameworks/data-binding/+/gradle_3.4.0/compiler/src/main/java/android/databinding/annotationprocessor/ProcessDataBinding.java#38

I suggest you check with the maintainers of that plugin or downgrade the version of Java.

Hi Duarte,

Thanks for quick update.Without Sonarqube integration I was able to compile sample code also (Same with my project).After integration with Sonar I see this exception.

After removing Sonarcube integration, how did you compile to see this issue (android studio?)

Can you pls let me know which downgrade Java version will help to resolve this.I am ok to downgrade it.

In my opinion as this exception I am seeing during sonarcube exception, Is there anyway can you help to suppress it while doing Sonarcube scanner?

i.e with below command?

./gradlew clean sonarqube -Dsonar.host.url=http://localhost:9000

Thanks,

Anil

The sonarqube tasks depends on compile and test tasks. See relevant code here:

Maybe a the failing task app:compileProdDebugJavaWithJavac is running because of this dependency, and would otherwise not run. You can try to run, without the sonarqube plugin, ./gradlew app:compileProdDebugJavaWithJavac and see if it works.
If that’s the problem, you could try to remove the problematic task dependency with something like sonarqube.dependsOn.remove("task-name").

I think JAXB was removed from JRE in Java 11, so downgrading to Java 8/9/10 should fix the problem.

Thanks Duarte.I tried below command for sonarcube and it generated report.
./gradlew clean app:compileProdDebugJavaWithJavac sonarqube -Dsonar.host.url=http://localhost:9000

Though still could not understand app:compileProdDebugJavaWithJavac as arguments it solve the issue compare to previous command.
./gradlew clean sonarqube -Dsonar.host.url=http://localhost:9000

Hello @akj,

I’m also having this same exact problem. I’ve configured my Gradle files the same way you did, Added JAX-B dependencies also.

But executing the above command I’m getting the following Exception:

What went wrong:
Task ‘compileProdDebugJavaWithJavac’ not found in project ‘:app’.

Could you please help me with this. I’m trying to solve this problem from 2 days now :expressionless:

Thanks

Hello @dmeneses

Following command is not working, can you help me with this please?

Getting Following Exception
What went wrong:
Task ‘compileProdDebugJavaWithJavac’ not found in project ‘:app’.

Hi. Please post the full stack trace of the exception.

Hello @dmeneses, thanks for the quick reply, when I added the plugin with sonar properties and executed with this command:

gradlew.bat clean sonarqube -Dsonar.host.url=http://localhost:9000

I get this following exception:

  > Task :app:kaptDebugKotlin FAILED
e: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
        at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3138)
        at java.base/java.lang.Class.getConstructor0(Class.java:3343)
        at java.base/java.lang.Class.newInstance(Class.java:556)
        at org.jetbrains.kotlin.cli.jvm.plugins.ServiceLoaderLite.loadImplementations(ServiceLoaderLite.kt:51)
        at org.jetbrains.kotlin.cli.jvm.plugins.ServiceLoaderLite.loadImplementations(ServiceLoaderLite.kt:44)
        at org.jetbrains.kotlin.kapt3.ClasspathBasedKapt3Extension$loadProcessors$efficientProcessorLoader$1.doLoadProcessors(Kapt3Extension.kt:83)
        at org.jetbrains.kotlin.kapt3.base.ProcessorLoader.loadProcessors(ProcessorLoader.kt:45)
        at org.jetbrains.kotlin.kapt3.base.ProcessorLoader.loadProcessors$default(ProcessorLoader.kt:28)
        at org.jetbrains.kotlin.kapt3.ClasspathBasedKapt3Extension.loadProcessors(Kapt3Extension.kt:88)
        at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.analysisCompleted(Kapt3Extension.kt:171)
        at org.jetbrains.kotlin.kapt3.ClasspathBasedKapt3Extension.analysisCompleted(Kapt3Extension.kt:98)
        at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM$analyzeFilesWithJavaIntegration$2.invoke(TopDownAnalyzerFacadeForJVM.kt:95)
        at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:105)
        at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:80)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:398)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:65)
        at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:107)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:389)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:118)
        at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:166)
        at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:56)
        at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:84)
        at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:42)
        at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:104)
        at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1$1$2.invoke(CompileServiceImpl.kt:442)
        at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1$1$2.invoke(CompileServiceImpl.kt:102)
        at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:1005)
        at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:102)
        at org.jetbrains.kotlin.daemon.common.DummyProfiler.withMeasure(PerfUtils.kt:138)
        at org.jetbrains.kotlin.daemon.CompileServiceImpl.checkedCompile(CompileServiceImpl.kt:1047)
        at org.jetbrains.kotlin.daemon.CompileServiceImpl.doCompile(CompileServiceImpl.kt:1004)
        at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:441)
        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:566)
        at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
        at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
        at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
        ... 50 more

So I added following JAX-B libraries into Build.gradle:

implementation "javax.xml.bind:jaxb-api:2.3.1"
implementation "com.sun.xml.bind:jaxb-core:2.3.0.1"
implementation "com.sun.xml.bind:jaxb-impl:2.3.2"
implementation "javax.activation:activation:1.1.1"

After this If I use same command:

gradlew.bat clean sonarqube -Dsonar.host.url=http://localhost:9000

I get the following error:

> Task :app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> javax/xml/bind/JAXBException

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 4m 5s
25 actionable tasks: 24 executed, 1 up-to-date

It is somewhat same as what @akj found, but I’m not able to solve this. Could you tell me what am I doing wrong?

Thanks

Hello @dmeneses
I think it is happening because of the data binding I’m using, as I’ve read it above in some of @akj posts. But I’m not sure. Do you think there’s any solution to this?? Or should I just give up :zipper_mouth_face: