SonarQube on Java8-project gives jacoco-Exception - java

I just downloaded the latest version, SonarQube 4.3,
then try build a java-8 project with:
mvn clean install
mvn sonar:sonar
That gives me the Exception below.
Googling, I got the impression this is an earlier issue that should have been fixed... ?
http://sonarqube.15.x6.nabble.com/Sonar-analyze-Java-1-8-project-Failure-td5023663.html
http://jira.codehaus.org/browse/SONARJAVA-482
Does SonarQube 4.3 support java-8?
Or any clue, what is the problem?
-------------------------------------------------------
T E S T S
-------------------------------------------------------
java.lang.reflect.InvocationTargetException
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:483)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Caused by: java.lang.RuntimeException: Class java/util/UUID could not be instrumented.
at org.jacoco.agent.rt.internal_6effb9e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:138)
at org.jacoco.agent.rt.internal_6effb9e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:99)
at org.jacoco.agent.rt.internal_6effb9e.PreMain.createRuntime(PreMain.java:55)
at org.jacoco.agent.rt.internal_6effb9e.PreMain.premain(PreMain.java:47)
... 6 more
Caused by: java.lang.NoSuchFieldException: $jacocoAccess
at java.lang.Class.getField(Class.java:1690)
at org.jacoco.agent.rt.internal_6effb9e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:136)
... 9 more
FATAL ERROR in native method: processing of -javaagent failed
Exception in thread "main"

I got the missing info from the SonarQube mailing-list...
To summarize:
To get Java8 maven-build working on SonarQube-4.3:
Install sonarqube-4.3, and start the server.
Login to the web-gui => Settings => Update Center => Plugins Updates => Java => Click "Upgrade to 2.2.1"
Wait a minute or so for the upgrade to complete... then shutdown+restart sonarqube.
Go back into the Upgrade Center and verify you have plugin: Java 2.2.1
To get code-coverage in Sonar, you now need to build with these commands:
mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install
mvn sonar:sonar
Reference: http://docs.codehaus.org/display/SONAR/JaCoCo+Plugin
That's it.

Here with java 11 I had this problem and I fix adding this in my gradle properties:
jacoco {
toolVersion = "0.8.4"
}

If you are running jacoco with gradle them update the jacoco to latest version.
I was also facing the similar issues and it got fixed after below changes
Java 11 and Gradle
jacoco {
toolVersion = "0.8.4"
}

I was getting the same error when mvn building a Java 1.7 project using JDK 1.8. The solution was simple: I changed the jacoco plugin version to a newer version:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.6.201602180812</version>
(The project was using version 0.6.3.201306030806 before.)

SonarQube 4.3 embeds Java plugin 2.1 whereas http://jira.codehaus.org/browse/SONARJAVA-482 has been fixed in version 2.2. So by upgrading the Java plugin to version 2.2.1, this should fix your issue.

Setting $JAVA_HOME resolved the problem for me.

We had the same issue. What we did was re-install sonarqube 4.3 with Java 8 already installed. Then run analysis against sonar. If you already have sonar/java 7 installed previously and have ran analysis against it, sonar seems to install some plugins which causes these failures. If you re-install just sonar and java 8 (dont remove mysql database etc... so history is intact) - re run your analysis it seems to solve the problem with the plugins.

I have done the following changes to come out from the problem.I have used the two steps for it , first one is that update the jacoco in latest version along with its toolVersion , please check it once below
classpath "com.dicedmelon.gradle:jacoco-android:0.1.4"
And toolVersion is as follow
jacoco {
toolVersion = "0.8.4"
}
Please refer the link for more info Click here
And now check the second step for it in which we use the excludes = ['jdk.internal.*'] inside the testOption like below
testOptions {
unitTests.all {
jacoco {
includeNoLocationClasses = true
excludes = ['jdk.internal.*']
}
}
}
For more info in it, please check the link Click here

Related

libGDX Error FAILURE: Build failed with an exception

This is the error I get from the console of the program and it won't let me even import the gradle to Eclipse
Generating app in C:\Users\mrgnh\Desktop\libGDXstuff
Executing 'C:\Users\mrgnh\Desktop\libGDXstuff/gradlew.bat clean --no-daemon'
To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/6.7.1/userguide/gradle_daemon.html.
Daemon will be stopped at the end of the build stopping after processing
FAILURE: Build failed with an exception.
Where:
Settings file 'C:\Users\mrgnh\Desktop\libGDXstuff\settings.gradle'
What went wrong:
Could not compile settings file 'C:\Users\mrgnh\Desktop\libGDXstuff\settings.gradle'.
startup failed:
General error during semantic analysis: Unsupported class file major version 60
It turns out I am blind and that libGDX does not support JDK 16 only 8-15
So when creating the gradle with the JDK 16 gradle System it wasn't working out
Try to change to latest gradle website version of gradle in file: Gradle -> Wrapper -> gradle-wrapper.properties
It helped me.

How to fix crash on launch in Android Studio 4?

It happened when after I installed some intellij related plugins after importing a native opencv project https://github.com/leadrien/opencv_native_androidstudio/blob/master/app/src/main/cpp/native-lib.cpp.
On startup it throws in this error.
Internal error. Please refer to https://code.google.com/p/android/issues
java.lang.ExceptionInInitializerError
at com.a.a.b.a.p.a(p.java:182)
at com.a.a.b.b.ar.a(ar.java:348)
at com.a.a.b.b.ar.a(ar.java:172)
at com.a.a.b.b.ar.a(ar.java:71)
at com.intellij.idea.MainImpl.start(MainImpl.java:19)
at com.intellij.idea.StartupUtil.lambda$startApp$5(StartupUtil.java:248)
at com.intellij.util.ui.EdtInvocationManager.executeWithCustomManager(EdtInvocationManager.java:73)
at com.intellij.idea.StartupUtil.startApp(StartupUtil.java:243)
at com.intellij.idea.StartupUtil.prepareApp(StartupUtil.java:214)
at com.intellij.ide.plugins.MainRunner.lambda$start$0(MainRunner.java:45)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
at com.intellij.ui.scale.JBUIScale.lambda$static$0(JBUIScale.java:72)
at com.intellij.openapi.util.AtomicNotNullLazyValue$1.compute(AtomicNotNullLazyValue.java:59)
at com.intellij.openapi.util.AtomicNotNullLazyValue.getValue(AtomicNotNullLazyValue.java:37)
at com.intellij.ui.scale.JBUIScale.lambda$static$1(JBUIScale.java:152)
at com.intellij.util.LazyInitializer$MutableNotNullValue.initialize(LazyInitializer.java:113)
at com.intellij.util.LazyInitializer$NullableValue.get(LazyInitializer.java:41)
at com.intellij.util.LazyInitializer$MutableNotNullValue.get(LazyInitializer.java:102)
at com.intellij.ui.scale.JBUIScale.lambda$static$2(JBUIScale.java:170)
at com.intellij.util.LazyInitializer$MutableNotNullValue.initialize(LazyInitializer.java:113)
at com.intellij.util.LazyInitializer$NullableValue.get(LazyInitializer.java:41)
at com.intellij.util.LazyInitializer$MutableNotNullValue.get(LazyInitializer.java:102)
at com.intellij.ui.scale.JBUIScale.scale(JBUIScale.java:294)
at com.intellij.util.ui.JBInsets.create(JBInsets.java:41)
at com.intellij.util.ui.UIUtil.<clinit>(UIUtil.java:457)
... 11 more
-----
JRE 1.8.0_242-release-1644-b3-6222593 amd64 by JetBrains s.r.o
/opt/android-studio/jre/jre
I solved this by delete three plugins under ~/.AndroidStudio4.0/config/plugins
idea-multimarkdown
markdown
Gauge-Java-Intellij
I solved it by deleting the latest plugins in ~/.AndroidStudio4.0/config/plugins/ Gauge-Java-Intellij and Markdown were causing issues in my case.
In my case, had problems with the markdown plugin.
I solved keeping the latest plugin in ~/.AndroidStudio4.0/config/plugins/ and removing the old version in .../android-studio-4.0.1/plugins/Kotlin/lib/markdown-0.1.25.jar.

Eclipse - Invalid classpath container: 'TestNG' in project and JUnit failed

I'm using Eclipse 4.9, I tried to update new TestNG upgrade(7)
It failed so I rollback to previous version and now I have an issue
'Invalid classpath container: 'TestNG' in project
I can't fix it by
clean project (maven can't be execute due to NullpointerException below errors)
Reinstall TestNG
Remove and add TestNG library
I didn't find relevant answers for this issue
Error log:
java.lang.NullPointerException
at org.eclipse.jem.workbench.utility.JavaModelListener.isInClasspath(JavaModelListener.java:367)
at org.eclipse.jem.workbench.utility.JavaModelListener.isInClasspath(JavaModelListener.java:412)
at org.eclipse.jem.workbench.utility.JavaModelListener.isInClasspath(JavaModelListener.java:384)
at org.eclipse.jem.workbench.utility.JavaModelListener.isInClasspath(JavaModelListener.java:305)
at org.eclipse.jem.internal.adapters.jdom.JavaReflectionSynchronizer.processJavaElementChanged(JavaReflectionSynchronizer.java:117)
at org.eclipse.jem.workbench.utility.JavaModelListener.processDelta(JavaModelListener.java:116)
at org.eclipse.jem.internal.adapters.jdom.JavaReflectionSynchronizer.processDelta(JavaReflectionSynchronizer.java:343)
at org.eclipse.jem.workbench.utility.JavaModelListener.processChildren(JavaModelListener.java:78)
at org.eclipse.jem.internal.adapters.jdom.JavaReflectionSynchronizer.processChildren(JavaReflectionSynchronizer.java:336)
at org.eclipse.jem.workbench.utility.JavaModelListener.processJavaElementChanged(JavaModelListener.java:176)
at org.eclipse.jem.workbench.utility.JavaModelListener.processDelta(JavaModelListener.java:113)
at org.eclipse.jem.internal.adapters.jdom.JavaReflectionSynchronizer.processDelta(JavaReflectionSynchronizer.java:343)
at org.eclipse.jem.workbench.utility.JavaModelListener.elementChanged(JavaModelListener.java:63)
at org.eclipse.jem.internal.adapters.jdom.JavaReflectionSynchronizer.elementChanged(JavaReflectionSynchronizer.java:265)
at org.eclipse.jdt.internal.core.DeltaProcessor$3.run(DeltaProcessor.java:1738)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
at org.eclipse.jdt.internal.core.DeltaProcessor.notifyListeners(DeltaProcessor.java:1726)
at org.eclipse.jdt.internal.core.DeltaProcessor.firePostChangeDelta(DeltaProcessor.java:1559)
at org.eclipse.jdt.internal.core.DeltaProcessor.fire(DeltaProcessor.java:1535)
at org.eclipse.jdt.internal.core.DeltaProcessor.notifyAndFire(DeltaProcessor.java:2256)
at org.eclipse.jdt.internal.core.DeltaProcessor.resourceChanged(DeltaProcessor.java:2146)
at org.eclipse.jdt.internal.core.DeltaProcessingState.resourceChanged(DeltaProcessingState.java:477)
at org.eclipse.core.internal.events.NotificationManager$1.run(NotificationManager.java:300)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
at org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:290)
at org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:153)
at org.eclipse.core.internal.resources.Workspace.broadcastPostChange(Workspace.java:379)
at org.eclipse.core.internal.resources.Workspace.endOperation(Workspace.java:1502)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:160)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:235)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
EDIT 1
Actually I failed to execute JUnit also
java.lang.NullPointerException
at org.eclipse.jdt.launching.JavaRuntime.processJavaLibraryPathEntries(J
avaRuntime.java:3037)
at org.eclipse.jdt.launching.JavaRuntime.processJavaLibraryPathEntries(J
avaRuntime.java:3049)
at org.eclipse.jdt.launching.JavaRuntime.gatherJavaLibraryPathEntries(Ja
vaRuntime.java:3000)
at org.eclipse.jdt.launching.JavaRuntime.computeJavaLibraryPath(JavaRunt
ime.java:2958)
at org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate.get
JavaLibraryPath(AbstractJavaLaunchConfigurationDelegate.java:1081)
at org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate.get
VMArguments(AbstractJavaLaunchConfigurationDelegate.java:598)
at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate.colle
ctExecutionArguments(JUnitLaunchConfigurationDelegate.java:376)
at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate.getVM
RunnerConfiguration(JUnitLaunchConfigurationDelegate.java:185)
at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate.launc
h(JUnitLaunchConfigurationDelegate.java:255)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConf
iguration.java:862)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConf
iguration.java:720)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlu
gin.java:1029)
at org.eclipse.debug.internal.ui.DebugUIPlugin$2.run(DebugUIPlugin.java:
1243)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
java.lang.NullPointerException
at org.eclipse.jdt.launching.JavaRuntime.processJavaLibraryPathEntries(J
avaRuntime.java:3037)
at org.eclipse.jdt.launching.JavaRuntime.processJavaLibraryPathEntries(J
avaRuntime.java:3049)
at org.eclipse.jdt.launching.JavaRuntime.gatherJavaLibraryPathEntries(Ja
vaRuntime.java:3000)
at org.eclipse.jdt.launching.JavaRuntime.computeJavaLibraryPath(JavaRunt
ime.java:2958)
at org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate.get
JavaLibraryPath(AbstractJavaLaunchConfigurationDelegate.java:1081)
at org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate.get
VMArguments(AbstractJavaLaunchConfigurationDelegate.java:598)
at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate.colle
ctExecutionArguments(JUnitLaunchConfigurationDelegate.java:376)
at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate.getVM
RunnerConfiguration(JUnitLaunchConfigurationDelegate.java:185)
at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate.launc
h(JUnitLaunchConfigurationDelegate.java:255)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConf
iguration.java:862)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConf
iguration.java:720)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlu
gin.java:1029)
at org.eclipse.debug.internal.ui.DebugUIPlugin$2.run(DebugUIPlugin.java:
1243)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
EDIT 2
Eclipse 4.10 doesn't support TestNG plugin to needed to downgrade to Eclipse Neon
TestNG is only available only for version till (4.9)2018-09 , you hv not made plug in for 2018-12.that's why it is not showing in marketplace
the recent release supports Eclipse Photon 2018-12:
https://github.com/cbeust/testng-eclipse/releases/tag/6.14.3.201902250526
please raise ticket on github if you still meet issue.
I had to manually (not using marketplace) TestNG version from http://beust.com/eclipse/
Notice there's warning about You are installing software that contains unsigned content

Dependency resolution fails on Gradle 5.1

I am facing an issue with my gradle project during migration to Gradle 5.1 from Gradle 4.10.2 :
Issue :
./gradlew clean build
> Task :subprojects:lib-abc-admin:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':subprojects:lib-abc-admin:compileJava'.
> Could not resolve all files for configuration ':subprojects:lib-abc-admin:compileClasspath'.
> Could not find org.glassfish.jersey:jersey-bom:.
Required by:
project :subprojects:lib-abc-admin
BUILD FAILED in 2s
In previous version Gradle 4.10.2, this error was getting circumvented by the following switch:
enableFeaturePreview("IMPROVED_POM_SUPPORT")
But in gradle 5 this switch has been deprecated, seems like this doesn't work anymore and I am getting the errors.
Any alternatives / suggestions / solutions ?
Toolchain Details :
------------------------------------------------------------
Gradle 5.1
------------------------------------------------------------
Kotlin DSL: 1.1.0
Kotlin: 1.3.11
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM: 11.0.1 (Oracle Corporation 11.0.1+13-LTS)
OS: Linux 4.19.8-200.fc28.x86_64 amd64
From gradle issue:
Different approaches were tried for supporting BOMs.
In Gradle 5.0, through feedback from the community (see #4422), we ended up deciding on an explicit notation to import a BOM.
So you will need to update dependencies on modules that are BOMs to that notation.
See documentation for details.
And since the IMPROVED_POM_SUPPORT feature is now enabled by default, you can remove the enableFeaturePreview("IMPROVED_POM_SUPPORT") line from your settings.gradle(.kts)

App with Spring and Hibernate does not compile on TeamCity with Java8 and Scala 2.11.8

after migration of my app to Scala 2.11.8 and Java8 and updating Spring and Hibernate to versions as Follow:
<spring.version>4.3.2.RELEASE</spring.version>
<spring.asm.version>3.1.4.RELEASE</spring.asm.version>
<spring.ws.version>2.3.0.RELEASE</spring.ws.version>
<spring.security.version>4.1.2.RELEASE</spring.security.version>
<spring.data.version>1.10.2.RELEASE</spring.data.version>
<hibernate.version>5.2.2.Final</hibernate.version>
<hibernate.validator.version>5.2.4.Final</hibernate.validator.version>
<hibernate.jpa.version>1.0.0.Final</hibernate.jpa.version>
Locally mvn clean install -U works completely fine. If I run the build on TeamCity I get error as follow:
[warn] Error reading API from class file : java.lang.UnsupportedClassVersionError: org/hibernate/jdbc/ReturningWork : Unsupported major.minor version 52.0
[17:03:33][Step 3/3] Failed to execute goal net.alchim31.maven:scala-maven-plugin:3.2.2:compile (scala-compile-first) on project app-jpa: Execution scala-compile-first of goal net.alchim31.maven:scala-maven-plugin:3.2.2:compile failed.
I try to compile it with java-8-openjdk-amd64/
Any ideas how to solve this?
Best
in my case I upgraded my JRE to the latest version, because the compiling version wasn't same as running version.

Categories