Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No running sonar-scanner with the new sonarqube 7.0 - NoClassDefFoundError: org/sonar/api/measures/PersistenceMode #118

Closed
davidfgc opened this issue Feb 6, 2018 · 10 comments · Fixed by #125

Comments

@davidfgc
Copy link

davidfgc commented Feb 6, 2018

It runs OK with sonarqube 6.7.1
Same project, same configuration file, same plugin version but with sonarqube 7.0 throws this error

ERROR: Error during SonarQube Scanner execution
java.lang.NoClassDefFoundError: org/sonar/api/measures/PersistenceMode
	at org.sonar.plugins.swift.complexity.LizardReportParser.buildMeasureList(LizardReportParser.java:128)
	at org.sonar.plugins.swift.complexity.LizardReportParser.addComplexityFileMeasures(LizardReportParser.java:116)
	at org.sonar.plugins.swift.complexity.LizardReportParser.parseFile(LizardReportParser.java:91)
	at org.sonar.plugins.swift.complexity.LizardReportParser.parseReport(LizardReportParser.java:64)
	at org.sonar.plugins.swift.complexity.LizardSensor.parseReportsIn(LizardSensor.java:66)
	at org.sonar.plugins.swift.complexity.LizardSensor.analyse(LizardSensor.java:57)
	at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:88)
	at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:82)
	at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:68)
	at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:88)
	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:180)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
	at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:288)
	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:283)
	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:261)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
	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:63)
	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:498)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
	at com.sun.proxy.$Proxy0.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.cli.Main.runAnalysis(Main.java:123)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:77)
	at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.lang.ClassNotFoundException: org.sonar.api.measures.PersistenceMode
	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)
	... 37 more
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
ERROR - Command 'sonar-scanner ' failed with error code: 1
@raja-M1993
Copy link

I have the same issue while running from the jenkins

@Hugal31
Copy link
Contributor

Hugal31 commented Feb 19, 2018

It is because some of the classes from sonar plugin API have been removed in the version 7 (they were deprecated since multiple versions).
There are org.sonar.api.measures.PersistenceMode and org.sonar.colorizer.CodeColorizerFormat.
I have forked the plugin and produced a quick-fix by removing the usage of these classes: https://github.com/Hugal31/sonar-swift/tree/fix/persistence-mode

Note that this is a quick-fix, and I can't say if the plugin works perfectly. However, I use it and I didn't notice any problem.

@raja-M1993
Copy link

@Hugal31

Thanks for your reply. I am using the CentOS environment and Sonarqube is a Community edition. Your solution is completely based on Mac environment. Can you please provide some inputs for CentOS env.

@Hugal31
Copy link
Contributor

Hugal31 commented Feb 20, 2018

@raja-M1993

Sorry, what is the problem, more precisely ?

Look at my two commits on my fork, I don't see anything that could tight the plugin to a Mac environment. Note that they are based on the develop branch, maybe some recent changes in the plugin trigger a problem in other environments ?

@duncillo
Copy link

@Hugal31

Could you create a full release for version 7 of sonar, for me? Thanks.

@Hugal31
Copy link
Contributor

Hugal31 commented Feb 26, 2018

Again, this is not a release. I am not a developer of sonar-swift. My fork is a quick-fix and I can't guarantee the reliability of it.

If you still want to use it, I have compiled the project and make it available here: https://github.com/Hugal31/sonar-swift/releases/tag/0.4-sonar-7-quick-fix

@duncillo
Copy link

@Hugal31 Thaks again

@JackLeo
Copy link

JackLeo commented Mar 9, 2018

@Hugal31 - yes your fixes are working. Tested on our system. Could you open a PR for this? Despite the shortcomings of the changes, that at least starts the conversation.

@malikubaid
Copy link

@Hugal31 I is your solution compatible with sonar 7.7 ?

@Hugal31
Copy link
Contributor

Hugal31 commented Jul 10, 2019

@malikubaid Sorry, I did not use Sonar for a long time, I can't tell :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants