“Class Not Found” during SonarQube analyse - jenkins

I have many errors with sonarqube analyse in the Jenkins job with the analyse success
[ERROR] [14:36:44.124] Class not found: org.joda.convert.FromString
[ERROR] [14:36:44.126] Class not found: org.joda.convert.ToString
[ERROR] [14:34:42.441] Class not found: org.apache.commons.logging.Log
[ERROR] [14:34:42.724] Class not found: org.apache.oro.text.perl.Perl5Util
[ERROR] [14:34:31.442] Class not found: io.swagger.annotations.ApiModel
[ERROR] [14:34:31.442] Class not found: io.swagger.annotations.ApiModelProperty
[ERROR] [14:28:37.756] Class not found: org.apache.commons.logging.Log
[ERROR] [14:28:40.030] Class not found: org.apache.oro.text.perl.Perl5Util
SonareQube : 5.1.2
sonarQube jenkins plugin : 2.6
JDK : 1.7
Any help please
thanks

Add the following dependency to your pom
<dependency>
<groupId>org.joda</groupId>
<artifactId>joda-convert</artifactId>
<version>1.8.1</version>
<scope>provided</scope>
</dependency>

This error is displayed when the .class file of the mentioned class is not found. This might results in less accurate and less precise issues raised.
You should check your analysis configuration and more specifically the sonar.java.libraries property to be sure you provide the correct dependency to your project.

The root cause in our case were outdated Sonar plugins. In order to figure out which one it is you need to run a Maven debug build i.e. run it with -X. The
Class not found: org.joda.convert.FromString
Class not found: org.joda.convert.ToString
you'll see if the sonar-jmeter-plugin is not up to date for example.

Related

I am migrating a project from maven to bazel and getting error

i am following the official bazel documentation for migrating from maven to bazel and used rules_jvm_external to defined external dependencies in workspace file and Build file. But I am getting the follwing error.
C:/users/kunal_visoulia/_bazel_kunal_visoulia/3f5dzdsz/external/maven/BUILD:1212:1: in deps attribute of jvm_import rule #maven//:commons_digester_commons_digester: rule '#maven//:xml_apis_xml_apis' does not exist
ERROR: Analysis of target '//:everything' failed; build aborted: Analysis of target '#maven//:commons_digester_commons_digester' failed; build aborted
INFO: Elapsed time: 724.364s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (4 packages loaded, 371 targets configured)
Fetching #remotejdk11_win; Restarting.
i am using private nexus repo and also the official maven repo. Please help
I've successfully reproduced your error and found the following workaround:
Add xml-apis:xml-apis:1.4.01 and junit:junit-dep:4.9 to your
list of artifacts.
Add the version_conflict_policy = "pinned"
attribute to maven_install.
The root cause is https://github.com/bazelbuild/rules_jvm_external/issues/250. The missing dependencies are artifacts that relocated to new GAV coordinates, which the coursier resolver cannot handle yet. The general workaround is to manually add the legacy GAV coordinates into maven_install.
Specifically, xml-apis:xml-apis:2.0.2 relocated to xml-apis:xml-apis:1.0.b2 (but 1.4.0.1 wasn't relocated), and junit:junit-dep:4.9 relocated to junit:junit.

Why SonarScanner ignores sonar.sources value (You must define the following mandatory properties)?

I would like you to help me with a problem that I have when executing: 'build now', because when I execute it the console output shows a series of failures
One of the failures was and still is, the properties of the file, I have already configured them and it is still giving faults, I have also saved them in the project directory, but nothing keeps failing.
these are the properties which i have in my project
sonar.projectKey=sistema_integracion
sonar.projectName=sistema_integracion
sonar.projectVersion=1.0
sonar.projectDescription=proyecto_asir
sonar.source=C:\Program Files (x86)\Jenkins\workspace\proyecto_integracion\spring_boot\src\main\java\hello
sonar.language=java
sonar.java.binaries=.
sonar.sourceEncoding=UTF-8
sonar.scm.disabled=True
-And these are the flaws , I would appreciate all the help possible.
Thank you so much.
ERROR: Error during SonarQube Scanner execution
ERROR: You must define the following mandatory properties for 'sistema_integracion': sonar.sources
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succeeded?
ERROR: SonarQube scanner exited with non-zero code: 1
Finished: FAILURE
Here is your problem:
ERROR: You must define the following mandatory properties for 'sistema_integracion': sonar.sources
You defined an absolute path:
sonar.source=C:\Program Files (x86)\Jenkins\workspace\proyecto_integracion\spring_boot\src\main\java\hello
The path must be relative. If this is your file structure:
sonar-project.properties
src
\-main
\-java
Then you should set:
sonar.sources=src/main/java

Jenkins Build Failure, Cobertura Error

I tried to build a job and it returns following error:
> Failed to execute goal
> org.codehaus.mojo:cobertura-maven-plugin:2.7:instrument (default-cli)
> on project addressbook: Execution default-cli of goal
> org.codehaus.mojo:cobertura-maven-plugin:2.7:instrument failed: Plugin
> org.codehaus.mojo:cobertura-maven-plugin:2.7 or one of its
> dependencies could not be resolved: Could not find artifact
> com.sun:tools:jar:0 at specified path
> /var/lib/jenkins/tools/hudson.model.JDK/myjava/../lib/tools.jar ->
> [Help 1]
Any idea how to resolve it?
I guess the jdk in question was above 8 which is still not supported by Cobertura: https://github.com/mojohaus/cobertura-maven-plugin/issues/30
[ERROR] Failed to execute goal
org.codehaus.mojo:cobertura-maven-plugin:2.7:instrument (verification)
on project generex: Execution verification of goal
org.codehaus.mojo:cobertura-maven-plugin:2.7:instrument failed: Plugin
org.codehaus.mojo:cobertura-maven-plugin:2.7 or one of its
dependencies could not be resolved: Could not find artifact
com.sun:tools:jar:0 at specified path
/usr/local/lib/jvm/openjdk11/../lib/tools.jar
I had to switch to https://www.jacoco.org/jacoco/ instead.
Seems like you are missing the tools jar in your JDK/JRE library you can confirm it by searching for the JAR in the lib folder if it's not present then you can add the following in your pom.xml
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.6.0</version>
<scope>system</scope>
<systemPath>${env.JAVA_HOME}/lib/tools.jar</systemPath>
</dependency>
Where ${env.JAVA_HOME} points to the JAVA you set in environment variables if you are using another JRE apart from the one set then specify the path like so /var/lib/jenkins/tools/hudson.model.JDK/myjava/JDK8/lib/lib
Hope it helps :)

taskdef class weblogic.ant.taskdefs.webservices.clientgen.ClientGenTask cannot be found

I am getting taskdef class weblogic.ant.taskdefs.webservices.clientgen.ClientGenTask cannot be found error while trying to build my project.
When googled I found that webserviceclient.jar may be required. But I am not sure in which folder I can get this jar.
I believe this task is within the following jar:
<weblogic install dir>/server/lib/webservices.jar
You can verify with:
jar -tf <weblogic install dir>/server/lib/webservices.jar | grep ClientGenTask

The rule 'OCLint:ivar assignment outside accessors or init' does not exist

I am trying to integrate SonarQube to generate report on my iOS project,
I am using Objective-C Sonar plugin
When i run ./run-sonar.sh
OCLint generates a compile_commands.json file in my root directory.
and after that getting following error
11:24:39.782 INFO - Processing OCLint report /Users/.......app/./sonar-reports/oclint.xml
11:24:39.899 ERROR - Reporting 1073 violations.
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 16.240s
Final Memory: 6M/86M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
at org.sonar.runner.api.Runner.execute(Runner.java:100)
at org.sonar.runner.Main.executeTask(Main.java:70)
at org.sonar.runner.Main.execute(Main.java:59)
at org.sonar.runner.Main.main(Main.java:53)
Caused by: The rule 'OCLint:ivar assignment outside accessors or init' does not exist.
Can any one help me on this issue?
Thanks
AMR
Thnaks
I had a similar error. My sonar server had two objective-c code analyser plugin. The Sonar Plugin for Objective C (free) and SonarSource Objective-C plugin (commercial)
When I removed (uninstalled) one of the plugin from sonar server the error stopped to occur
I had a similar error too with the last version of this plugin which is a fork of the one you used.
I downgrade my OCLint version from 0.11 to 0.10.1 and everything work perfectly.
It seems that the OCLint rules defined in the plugin was different of the OCLint version installed on my server.
I am not sure what version of the objective-c-sonar plugin that you were using.
I solved similar issue before.
Goto ${SONAR_INSTALLATION_FOLDER}/extensions/plugins/, copy the sonar-objective-c-plugin-${version}.jar to somewhere else.
unzip the jar file, and edit below file
org/sonar/plugins/objectivec/profile-oclint.xml
Add the rule you are missing following the layout of the xml file,
may be look similar below
<rule>
<repositoryKey>OCLint</repositoryKey>
<key>ivar assignment outside accessors or init</key>
</rule>
And edit another file org/sonar/plugins/objectivec/rules-oclint.xml
<rule>
<key>ivar assignment outside accessors or init</key>
<name>ivar assignment outside accessors or init</name>
<priority>MAJOR</priority>
<description>ivar assignment outside accessors or init</description>
</rule>
And then using zip to package the files unpacked as the new jar file.
Override the original plugin jar file in ${SONAR_INSTALLATION_FOLDER}/extensions/plugins/, restart the sonar, issue could be gone.
Repeat the step for all similar issues you encountered.

Resources