Hi,
I just upgraded from version 10.4 to version 10.5 and I’m encountering an error during the scan of my projects I suppose because of my custom plugin and the new feature to only download required plugins for the scan :
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.11.0.3922:sonar (default-cli) on project company-project-parent:
Error creating bean with name 'org.sonarsource.scanner.api.internal.IsolatedClassloader@5d7911d5-org.sonar.scanner.bootstrap.ScannerPluginRepository':
Initialization of bean failed; nested exception is java.lang.NullPointerException:
Cannot invoke "org.sonar.core.platform.ExplodedPlugin.getPluginInfo()" because the return value of "java.util.Map.get(Object)" is null
[...]
[Root exception :]
Caused by: java.lang.NullPointerException: Cannot invoke "org.sonar.core.platform.ExplodedPlugin.getPluginInfo()" because the return value of "java.util.Map.get(Object)" is null
at org.sonar.core.platform.PluginClassLoader.basePluginKey (PluginClassLoader.java:167)
at org.sonar.core.platform.PluginClassLoader.defineClassloaders (PluginClassLoader.java:82)
at org.sonar.core.platform.PluginClassLoader.load (PluginClassLoader.java:66)
A strange log I saw, considering my project is composed of a java server + client, when I ran the scan in debug is this :
[DEBUG] 12:12:21.865 Plugins not loaded because they are optional: [abap, csharp, cpp, checkstyle, dbd, dbdjavafrontend, dbdpythonfrontend, findbugs, flex, go, web, java, javascript, kotlin, php, plsql, ruby, sonarscala, swift, tsql, vbnet, security, securitycsharpfrontend, securityjsfrontend, securityjavafrontend, securityphpfrontend, securitypythonfrontend]
Here is my plugin packaging configuration :
<plugin>
<groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
<artifactId>sonar-packaging-maven-plugin</artifactId>
<version>1.23.0.740</version>
<extensions>true</extensions>
<configuration>
<pluginKey>company-java</pluginKey>
<pluginName>Company Custom Java Rules</pluginName>
<pluginDescription>Company custom sonar rules</pluginDescription>
<pluginClass>com.company.sonar.CompanyRulesPlugin</pluginClass>
<pluginDisplayVersion>1.8.0</pluginDisplayVersion>
<sonarLintSupported>true</sonarLintSupported>
<pluginApiMinVersion>10.6.0.2114</pluginApiMinVersion>
<basePlugin>java</basePlugin>
<skipDependenciesPackaging>true</skipDependenciesPackaging>
<requiredForLanguages>java</requiredForLanguages>
</configuration>
</plugin>
and here is the corresponding generated Manifest :
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven 3.9.6
Built-By: [me]
Build-Jdk: 17.0.1
Plugin-ChildFirstClassLoader: false
Plugin-Developers:
Plugin-License:
SonarLint-Supported: true
Plugin-Key: companyjava
Plugin-BuildDate: 2024-04-18T11:04:44+0000
Plugin-Version: 1.8.0
Plugin-Organization: Company
Plugin-Name: Company Custom Java Rules
Plugin-Class: com.company.sonar.CompanyRulesPlugin
Plugin-RequiredForLanguages: java
Plugin-Description: Company custom sonar rules
Plugin-Display-Version: 1.8.0
Sonar-Version: 10.6.0.2114
Plugin-SourcesUrl: https://repository.company.com/tooling/sonar-extra-rules.
git
Plugin-Base: java
Plugin-RequirePlugins: java:7.31.0.34839
I disabled my plugin (renamed it on the server plugin.jar.bak) and the scanner works fine.
There are no depreciation warning or compile error in my plugin code so I don’t know what I’m missing.
There is one strange thing I just saw while making this post. In maven and in my code, my plugin key is company-java
but in the manifest, it is companyjava
maybe the problem comes from here but I saw nowhere that the plugin key could not have hyphens.
Considering the code fails where a pluginKey is given to a Map to retrieve the parent plugin it could be related.
I also tested building with pluginApiMinVersion=10.7.0.2191
and Plugin-RequirePlugins: java:7.33.0.35775
to no avail.