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

NoSuchMethodError with SonarQube 6 #6

Open
marco-ceriani opened this issue Jul 17, 2017 · 4 comments
Open

NoSuchMethodError with SonarQube 6 #6

marco-ceriani opened this issue Jul 17, 2017 · 4 comments

Comments

@marco-ceriani
Copy link

The plugin does not work with SonarQube version 6.4 and sonar scanner 3.0.3.778. It seems that one API was removed.

14:29:11.505 ERROR: Error during SonarQube Scanner execution java.lang.NoSuchMethodError: org.sonar.api.resources.File.fromIOFile(Ljava/io/File;Lorg/sonar/api/resources/Project;)Lorg/sonar/api/resources/File; at org.sonarqube.cppcheck.CppcheckSensor.save(CppcheckSensor.java:103) at org.sonarqube.cppcheck.CppcheckSensor.saveAll(CppcheckSensor.java:80) at org.sonarqube.cppcheck.CppcheckSensor.analyse(CppcheckSensor.java:73) at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:87) at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:81) at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:67) at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:75) at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:178) at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:144) at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:129) at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:259) at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:254) at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:243) at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:144) at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:129) at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:47) at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:86) at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:144) at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:129) at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:118) at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:117) 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)

@creib
Copy link

creib commented Dec 7, 2017

I have the same error after activating the plugin in sonar 6.7.

@Mulugruntz
Copy link

The problem comes from this line.

Same problem here on sonar 7.0.
Here it says that it's deprecated in 5.4: http://javadocs.sonarsource.org/5.4/apidocs/org/sonar/api/resources/File.html#fromIOFile(java.io.File,%20org.sonar.api.resources.Project)
So it has been removed in 6.x.

We can see that in 6.7 it says that File has been deprecated in favour of InputFile:
http://javadocs.sonarsource.org/6.7/apidocs/org/sonar/api/resources/File.html
http://javadocs.sonarsource.org/6.7/apidocs/org/sonar/api/batch/fs/InputFile.html

So, all in all, I believe the fix would be something like:

final Resource resource;
// ...
resource = org.sonar.api.resources.File.fromIOFile(file, project);
final DefaultInputFile inputFile;
// ...
InputFile file = org.sonar.api.batch.fs.inputFile(fs.predicates().hasRelativePath(file.path()));

There will be of course other changes (signatures...) to be done. But that should not take more than a day to whoever wants to fix it (and knows a bit of Java/the codebase).

@Mulugruntz
Copy link

I would put this as top-priority as this means the whole plugin cannot be used in sonar 6.0+. And the LTS is 6.7.

@rompic
Copy link

rompic commented Jul 22, 2018

@Mulugruntz you may like to try https://github.com/SonarOpenCommunity/sonar-cxx instead

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

No branches or pull requests

4 participants