[system.err] Error: Could not find or load main class org.sonar.runner.Main

sonarqube

(Kamal Ahmed) #1

I am trying to upgrade sonar-runner from 2.4 to 2.5, using gradle version 2.3

here is the snippet from build.gradle:

classpath ‘org.codehaus.sonar.runner:sonar-runner-dist:2.5’

and i use the following to upload the sonar-runner-dist-2.5.jar

org.codehaus.sonar.runner sonar-runner-dist 2.5

to nexus

but cannot seem to run sonar-runner


(Benjamin Muschko) #2

You’ll need to change the version via the exposed DSL:

sonarRunner {
    toolVersion = '2.5'
}

For more information please see the plugin’s documentation page.


(Kamal Ahmed) #3

Thanks for your response @bmuschko

in build.gradle

sonarRunner{
         toolVersion = "2.5"
         sonarProperties{
            property "sonar.analysis.mode", "preview"
            property "sonar.issuesReport.html.enable", "true"
            property "sonar.cobertura.reportPath", file("${projectDir}/build/reports/cobertura/coverage.xml")

its there


(Kamal Ahmed) #4

could it be a $CLASSPATH issue ? since i am running the gradle command on linux host A, and the sonarQube is on host B, and Nexus is on host C

i also manually copy the sonar-runner-dist-2.5.jar file on host A, and run the command manually like:

java -jar sonar-runner-dist-2.5.jar
INFO: Runner configuration file: NONE
INFO: Project configuration file: NONE
INFO: SonarQube Runner 2.5-RC1
INFO: Java 1.7.0_80 Oracle Corporation (64-bit)
INFO: Linux 2.6.32-504.1.3.el6.x86_64 amd64
to see if the jar is ok.

But HOW would gradle task know where is the jar file and how to run it ? unless the $CLASSPATH is set ?
but since gradle would download the jar file upon execution, not sure how i would setup the $CLASSPATH for java to know where the jar is.
Makes sense ?


(Benjamin Muschko) #5

Possibly the SonarQube project moved the main class to a different package or renamed it. If you look at the contents of the JAR file, do you find this class?


(Kamal Ahmed) #6

not sure where to look:

unzip sonar-runner-dist-2.5.jar
Archive: sonar-runner-dist-2.5.jar
creating: META-INF/
inflating: META-INF/MANIFEST.MF
creating: org/
creating: org/sonar/
creating: org/sonar/runner/
creating: org/sonar/runner/cli/
inflating: org/sonar/runner/cli/RunnerFactory$1.class
inflating: org/sonar/runner/cli/Shutdown$ShutdownHook.class
inflating: org/sonar/runner/cli/Logs.class
inflating: org/sonar/runner/cli/Shutdown.class
inflating: org/sonar/runner/cli/RunnerFactory.class
inflating: org/sonar/runner/cli/Conf.class
inflating: org/sonar/runner/cli/SystemInfo$System2.class
inflating: org/sonar/runner/cli/Shutdown$1.class
inflating: org/sonar/runner/cli/SystemInfo.class
inflating: org/sonar/runner/cli/package-info.class
inflating: org/sonar/runner/cli/Main.class
inflating: org/sonar/runner/cli/Stats.class
inflating: org/sonar/runner/cli/Cli.class
inflating: org/sonar/runner/cli/RunnerFactory$DefaultLogOutput.class
inflating: org/sonar/runner/cli/Exit.class
creating: META-INF/maven/
creating: META-INF/maven/org.sonarsource.sonar-runner/
creating: META-INF/maven/org.sonarsource.sonar-runner/sonar-runner-dist/
inflating: META-INF/maven/org.sonarsource.sonar-runner/sonar-runner-dist/pom.xml
inflating: META-INF/maven/org.sonarsource.sonar-runner/sonar-runner-dist/pom.properties
inflating: sonar-runner-batch.jar
creating: org/sonar/runner/impl/
inflating: org/sonar/runner/impl/IsolatedLauncherProxy.class
inflating: org/sonar/runner/impl/IsolatedLauncherFactory.class
inflating: org/sonar/runner/impl/JarDownloader.class
inflating: org/sonar/runner/impl/VersionUtils.class
inflating: org/sonar/runner/impl/JarExtractor.class
inflating: org/sonar/runner/impl/IsolatedLauncherFactory$1.class
inflating: org/sonar/runner/impl/TempCleaning.class
inflating: org/sonar/runner/impl/IsolatedClassloader.class
inflating: org/sonar/runner/impl/package-info.class
inflating: org/sonar/runner/impl/Jars$BatchFileDownloader.class
inflating: org/sonar/runner/impl/Jars.class
inflating: org/sonar/runner/impl/ServerConnection.class
inflating: org/sonar/runner/impl/SimulatedLauncher.class
inflating: org/sonar/runner/impl/ClassloadRules.class
inflating: org/sonar/runner/impl/RunnerException.class
creating: org/sonar/runner/cache/
inflating: org/sonar/runner/cache/FileCache.class
inflating: org/sonar/runner/cache/FileCache$Downloader.class
inflating: org/sonar/runner/cache/DeleteFileOnCloseInputStream.class
inflating: org/sonar/runner/cache/DirectoryLock.class
inflating: org/sonar/runner/cache/FileHashes.class
inflating: org/sonar/runner/cache/package-info.class
inflating: org/sonar/runner/cache/PersistentCache.class
inflating: org/sonar/runner/cache/FileCacheBuilder.class
inflating: org/sonar/runner/cache/Logger.class
inflating: org/sonar/runner/cache/PersistentCacheBuilder.class
inflating: org/sonar/runner/cache/PersistentCache$1.class
inflating: org/sonar/runner/cache/TTLCacheInvalidation.class
inflating: org/sonar/runner/cache/PersistentCache$DirectoryCleanFilter.class
inflating: org/sonar/runner/cache/PersistentCache$DirectoryClearFilter.class
inflating: org/sonar/runner/cache/PersistentCacheInvalidation.class
creating: org/sonar/runner/api/
inflating: org/sonar/runner/api/IssueListenerAdapter.class
inflating: org/sonar/runner/api/LogOutput$Level.class
inflating: org/sonar/runner/api/Dirs.class
inflating: org/sonar/runner/api/Utils$1.class
inflating: org/sonar/runner/api/IssueListener.class
inflating: org/sonar/runner/api/EmbeddedRunner.class
inflating: org/sonar/runner/api/EmbeddedRunner$1.class
inflating: org/sonar/runner/api/LogOutput.class
inflating: org/sonar/runner/api/package-info.class
inflating: org/sonar/runner/api/Issue.class
inflating: org/sonar/runner/api/RunnerVersion.class
inflating: org/sonar/runner/api/Issue$1.class
inflating: org/sonar/runner/api/Utils.class
inflating: org/sonar/runner/api/version.txt
inflating: org/sonar/runner/api/Utils$DeleteQuietlyFileVisitor.class
inflating: org/sonar/runner/api/Issue$Builder.class
inflating: org/sonar/runner/api/LoggerAdapter.class
creating: META-INF/maven/org.sonarsource.sonar-runner/sonar-runner-api/
inflating: META-INF/maven/org.sonarsource.sonar-runner/sonar-runner-api/pom.xml
inflating: META-INF/maven/org.sonarsource.sonar-runner/sonar-runner-api/pom.properties
creating: org/sonar/runner/kevinsawicki/
inflating: org/sonar/runner/kevinsawicki/HttpRequest$1.class
inflating: org/sonar/runner/kevinsawicki/HttpRequest$10.class
inflating: org/sonar/runner/kevinsawicki/HttpRequest$2.class
inflating: org/sonar/runner/kevinsawicki/HttpRequest$3.class
inflating: org/sonar/runner/kevinsawicki/HttpRequest$4.class
inflating: org/sonar/runner/kevinsawicki/HttpRequest$5.class
inflating: org/sonar/runner/kevinsawicki/HttpRequest$6.class
inflating: org/sonar/runner/kevinsawicki/HttpRequest$7.class
inflating: org/sonar/runner/kevinsawicki/HttpRequest$8.class
inflating: org/sonar/runner/kevinsawicki/HttpRequest$9.class
inflating: org/sonar/runner/kevinsawicki/HttpRequest$Base64.class
inflating: org/sonar/runner/kevinsawicki/HttpRequest$CloseOperation.class
inflating: org/sonar/runner/kevinsawicki/HttpRequest$FlushOperation.class
inflating: org/sonar/runner/kevinsawicki/HttpRequest$HttpRequestException.class
inflating: org/sonar/runner/kevinsawicki/HttpRequest$Operation.class
inflating: org/sonar/runner/kevinsawicki/HttpRequest$RequestOutputStream.class
inflating: org/sonar/runner/kevinsawicki/HttpRequest.class
creating: META-INF/maven/com.github.kevinsawicki/
creating: META-INF/maven/com.github.kevinsawicki/http-request/
inflating: META-INF/maven/com.github.kevinsawicki/http-request/pom.xml
inflating: META-INF/maven/com.github.kevinsawicki/http-request/pom.properties
inflating: META-INF/LICENSE.txt
inflating: META-INF/NOTICE.txt
creating: org/sonar/runner/commonsio/
inflating: org/sonar/runner/commonsio/Charsets.class
inflating: org/sonar/runner/commonsio/FileExistsException.class
creating: org/sonar/runner/commonsio/filefilter/
inflating: org/sonar/runner/commonsio/filefilter/AbstractFileFilter.class
inflating: org/sonar/runner/commonsio/filefilter/AgeFileFilter.class
inflating: org/sonar/runner/commonsio/filefilter/AndFileFilter.class
inflating: org/sonar/runner/commonsio/filefilter/ConditionalFileFilter.class
inflating: org/sonar/runner/commonsio/filefilter/DelegateFileFilter.class
inflating: org/sonar/runner/commonsio/filefilter/DirectoryFileFilter.class
inflating: org/sonar/runner/commonsio/filefilter/FalseFileFilter.class
inflating: org/sonar/runner/commonsio/filefilter/FileFileFilter.class
inflating: org/sonar/runner/commonsio/filefilter/FileFilterUtils.class
inflating: org/sonar/runner/commonsio/filefilter/IOFileFilter.class
inflating: org/sonar/runner/commonsio/filefilter/MagicNumberFileFilter.class
inflating: org/sonar/runner/commonsio/filefilter/NameFileFilter.class
inflating: org/sonar/runner/commonsio/filefilter/NotFileFilter.class
inflating: org/sonar/runner/commonsio/filefilter/OrFileFilter.class
inflating: org/sonar/runner/commonsio/filefilter/PrefixFileFilter.class
inflating: org/sonar/runner/commonsio/filefilter/SizeFileFilter.class
inflating: org/sonar/runner/commonsio/filefilter/SuffixFileFilter.class
inflating: org/sonar/runner/commonsio/filefilter/TrueFileFilter.class
inflating: org/sonar/runner/commonsio/FilenameUtils.class
inflating: org/sonar/runner/commonsio/FileUtils.class
creating: org/sonar/runner/commonsio/input/
inflating: org/sonar/runner/commonsio/input/ClosedInputStream.class
inflating: org/sonar/runner/commonsio/IOCase.class
inflating: org/sonar/runner/commonsio/IOUtils.class
inflating: org/sonar/runner/commonsio/LineIterator.class
creating: org/sonar/runner/commonsio/output/
inflating: org/sonar/runner/commonsio/output/ByteArrayOutputStream.class
inflating: org/sonar/runner/commonsio/output/NullOutputStream.class
inflating: org/sonar/runner/commonsio/output/StringBuilderWriter.class
creating: META-INF/maven/commons-io/
creating: META-INF/maven/commons-io/commons-io/
inflating: META-INF/maven/commons-io/commons-io/pom.xml
inflating: META-INF/maven/commons-io/commons-io/pom.properties
creating: org/sonar/runner/batch/
inflating: org/sonar/runner/batch/LogOutput$Level.class
inflating: org/sonar/runner/batch/IssueListener$Issue.class
inflating: org/sonar/runner/batch/IssueListener.class
inflating: org/sonar/runner/batch/LogOutput.class
inflating: org/sonar/runner/batch/IsolatedLauncher.class
creating: META-INF/maven/org.sonarsource.sonar-runner/sonar-runner-batch-interface/
inflating: META-INF/maven/org.sonarsource.sonar-runner/sonar-runner-batch-interface/pom.xml
inflating: META-INF/maven/org.sonarsource.sonar-runner/sonar-runner-batch-interface/pom.properties


(Benjamin Muschko) #7

I only see the class org/sonar/runner/cli/Main.class which doesn’t line up with the hard-coded class name in the plugin. That’s why it is failing for you. The plugin code is not compatible with the library version anymore.

BTW: The SonarRunner plugin in Gradle core is superseded by an external plugin. Please use the external plugin. They might have fixed the issue.


(Kamal Ahmed) #8

git diff build.gradle
diff --git a/build.gradle b/build.gradle

 index 111f1ed..b6e9f2a 100644
    — a/build.gradle
    +++ b/build.gradle
    @@ -90,7 +90,8 @@ buildscript {
    }
    dependencies
    { classpath 'gov.dhs.uscis.elis2:crypto-plugin:0.1.4' - classpath 'org.codehaus.sonar.runner:sonar-runner-dist:2.4' + //classpath 'org.codehaus.sonar.runner:sonar-runner-dist:2.5' + classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.5' classpath 'net.saliman:gradle-cobertura-plugin:2.2.7' }
    @@ -139,7 +140,7 @@ subprojects {
    if(sonarProjects.contains(project.getPath()) && rootProject.hasProperty('sonar') ){
    apply plugin: 'net.saliman.cobertura'
    apply plugin: 'sonar-runner'
    + apply plugin: 'org.sonarqube'
    cobertura {
    coverageDirs << file("$
    {projectDir}/build/classes/main")
    @@ -149,9 +150,9 @@ subprojects {
    }
    project.tasks.generateCoberturaReport.outputs.file file("${projectDir}
    /build/reports/cobertura/coverage.xml")
    project.tasks.cobertura.outputs.dir file("$
    {projectDir}/build/cobertura")
    -
    - sonarRunner{
    - toolVersion = "2.4"
    +
    + sonarqube{
    + toolVersion = "2.5"
    sonarProperties{
    property "sonar.analysis.mode", "preview"
    property "sonar.issuesReport.html.enable", "true"
    @@ -165,8 +166,8 @@ subprojects {
    systemProperty "sonar.host.url", "http://${sonar}"
    systemProperty "project.settings","${projectDir}
    /build/tmp/sonarRunner/sonar-project.properties"
    environment = System.getenv()
    maxHeapSize = '768m'
    jvmArgs '-XX:MaxPermSize=256m'
    + maxHeapSize = '2048m'
    + jvmArgs '-XX:MaxPermSize=2048m'
    }
    }

and i get error:
/opt/gradle/gradle-2.7/bin/gradle -PcodeCoverageType=xml -Ptls.key.store=/opt/keystore/JavaKeyStore.jks -Ptls.trusted.store=/opt/keystore/JavaKeyStore.jks -PpbeKeyFile=/elis2/apps/Shared/Crypto/src/main/resources/pbe.dat -PreleaseDeploy=false -Dorg.gradle.daemon=true :noINT :Backend:Elis2Services:sonarqube
properties decrypted with keyfile /elis2/apps/Shared/Crypto/src/main/resources/pbe.dat
Incremental java compilation is an incubating feature.
FAILURE: Build failed with an exception.
Where:
Build file ‘/elis2/apps/build.gradle’ line: 143
What went wrong:
A problem occurred evaluating root project ‘apps’.
> Plugin with id ‘sonarqube’ not found.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 17.665 secs

This is what i use in Nexus:

org.codehaus.sonar.scanner
sonar-runner-cli
2.5

and upload the following jar in the lib folder:
https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-2.5.zip


(Benjamin Muschko) #9

Looks like you are already using the external SonarQube plugin. In this case I’d suggest you ask on their project forum/GitHub.

BTW: For future posts could you please properly format your code snippet. They are pretty much unreadable which makes it hard for someone to help.