Error adding a sonarQube rules plug-in

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube 8.0, No Extra plug-ins installed)
  • what are you trying to achieve
  • We are trying to add more custom affinity rules for COBOL especially on CICS
  • tried renaming it but still not working

Read this on the net but not sure what it means :

==It assumes that the JAR file of the COBOL analyzer (file sonar-cobol-plugin-4.0.0.2525.jar) is ==available in the “lib” directory. You can download the JAR file of the COBOL analyzer from ==the SonarSource website.

  • what have you tried so far to achieve this
  • We have created a maven project using the sample/example found in GitHub - https://docs.sonarqube.org/latest/analysis/languages/cobol/
  • Once we generated the jar file, when I add the jar file as a plug-in (D:\Program files\sonarqube-enterprise-8.0\sonarqube-8.0\extensions\plugins) and restart the SonarQube server it does not work .
    SonarQube a message …Web server startup failed: File is not a plugin. Please delete it and restart: D:\Program files\sonarqube-enterprise-8.0\sonarqube-8.0\extensions\plugins\sonar-example-plugin.jar
--> Wrapper Started as Service Launching a JVM... Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved.

2020.08.16 18:50:58 INFO app[o.s.a.AppFileSystem] Cleaning or creating temp directory D:\Program files\sonarqube-enterprise-8.0\sonarqube-8.0\temp
2020.08.16 18:50:58 INFO app[o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
2020.08.16 18:50:58 INFO app[o.s.a.ProcessLauncherImpl] Launch process[[key=‘es’, ipcIndex=1, logFilenamePrefix=es]] from [D:\Program files\sonarqube-enterprise-8.0\sonarqube-8.0\elasticsearch]: C:\Program Files\Java\jdk-11.0.5\bin\java -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -XX:-OmitStackTraceInFastThrow -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Djava.io.tmpdir=D:\Program files\sonarqube-enterprise-8.0\sonarqube-8.0\temp -XX:ErrorFile=…/logs/es_hs_err_pid%p.log -Des.enforce.bootstrap.checks=true -Xmx2G -Xms2G -XX:+HeapDumpOnOutOfMemoryError -Delasticsearch -Des.path.home=D:\Program files\sonarqube-enterprise-8.0\sonarqube-8.0\elasticsearch -Des.path.conf=D:\Program files\sonarqube-enterprise-8.0\sonarqube-8.0\temp\conf\es -cp lib/* org.elasticsearch.bootstrap.Elasticsearch
Java HotSpot™ 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
2020.08.16 18:50:58 INFO app[o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
2020.08.16 18:50:58 INFO app[o.e.p.PluginsService] no modules loaded
2020.08.16 18:50:58 INFO app[o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin]
2020.08.16 18:51:10 INFO app[o.s.a.SchedulerImpl] Process[es] is up
2020.08.16 18:51:10 INFO app[o.s.a.ProcessLauncherImpl] Launch process[[key=‘web’, ipcIndex=2, logFilenamePrefix=web]] from [D:\Program files\sonarqube-enterprise-8.0\sonarqube-8.0]: C:\Program Files\Java\jdk-11.0.5\bin\java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=D:\Program files\sonarqube-enterprise-8.0\sonarqube-8.0\temp --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED -Xmx1G -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Dhttp.nonProxyHosts=localhost|127.|[::1] -cp ./lib/common/;D:\Program files\sonarqube-enterprise-8.0\sonarqube-8.0\lib\jdbc\postgresql\postgresql-42.2.5.jar org.sonar.server.app.WebServer D:\Program files\sonarqube-enterprise-8.0\sonarqube-8.0\temp\sq-process7558890823651482401properties
2020.08.16 18:51:15 INFO app[o.s.a.SchedulerImpl] Process[web] is stopped
2020.08.16 18:51:15 INFO app[o.s.a.SchedulerImpl] Process[es] is stopped
2020.08.16 18:51:15 INFO app[o.s.a.SchedulerImpl] SonarQube is stopped
<-- Wrapper Stopped

Does the pom.xml of your project contain a block to set up sonar-packaging-maven-plugin as in the example plugin?
How did you generate the JAR file? Can you provide the output of the maven command you used to generate the JAR?

Hi Pierre,

Thank you very much for the response , we went through the setup again and re-generated the jar file and this it did recognise it as a plugin even it gave error below.

I have attached the

2020.08.20 20:19:15 INFO web[o.s.s.s.GeneratePluginIndex] Generate scanner plugin index

2020.08.20 20:19:15 INFO web[o.s.s.s.RegisterPlugins] Register plugins

2020.08.20 20:19:15 INFO web[o.s.s.s.RegisterMetrics] Register metrics

2020.08.20 20:19:15 INFO web[o.s.s.r.RegisterRules] Register rules

2020.08.20 20:19:15 ERROR web[o.s.s.p.Platform] Background initialization failed. Stopping SonarQube

java.lang.IllegalStateException: Resource not found: /org/sonar/l10n/cobol/rules/cobol/GetmainCommandUsage.html

at com.mycompany.cobol.sample.CobolCustomCheckRepository.loadResource(CobolCustomCheckRepository.java:98)

at com.mycompany.cobol.sample.CobolCustomCheckRepository.lambda$2(CobolCustomCheckRepository.java:79)

at java.base/java.util.HashMap$Values.forEach(HashMap.java:976)

at com.mycompany.cobol.sample.CobolCustomCheckRepository.define(CobolCustomCheckRepository.java:79)

at org.sonar.server.rule.RuleDefinitionsLoader.load(RuleDefinitionsLoader.java:57)

at org.sonar.server.rule.RegisterRules.start(RegisterRules.java:119)

at org.sonar.core.platform.StartableCloseableSafeLifecyleStrategy.start(StartableCloseableSafeLifecyleStrategy.java:40)

at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84)

at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169)

at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132)

at org.picocontainer.behaviors.Stored.start(Stored.java:110)

at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1016)

at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1009)

at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:767)

at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)

at org.sonar.server.platform.platformlevel.PlatformLevel.start(PlatformLevel.java:90)

at org.sonar.server.platform.platformlevel.PlatformLevelStartup.access$001(PlatformLevelStartup.java:48)

at org.sonar.server.platform.platformlevel.PlatformLevelStartup$1.doPrivileged(PlatformLevelStartup.java:85)

at org.sonar.server.user.DoPrivileged.execute(DoPrivileged.java:46)

at org.sonar.server.platform.platformlevel.PlatformLevelStartup.start(PlatformLevelStartup.java:82)

at org.sonar.server.platform.PlatformImpl.executeStartupTasks(PlatformImpl.java:198)

at org.sonar.server.platform.PlatformImpl.access$400(PlatformImpl.java:46)

at org.sonar.server.platform.PlatformImpl$1.lambda$doRun$1(PlatformImpl.java:122)

at org.sonar.server.platform.PlatformImpl$AutoStarterRunnable.runIfNotAborted(PlatformImpl.java:370)

at org.sonar.server.platform.PlatformImpl$1.doRun(PlatformImpl.java:122)

at org.sonar.server.platform.PlatformImpl$AutoStarterRunnable.run(PlatformImpl.java:354)

at java.base/java.lang.Thread.run(Thread.java:834)

2020.08.20 20:19:16 INFO web[o.s.p.ProcessEntryPoint] Hard stopping process

2020.08.20 20:19:16 INFO web[o.s.s.n.NotificationDaemon] Notification service stopped

2020.08.20 20:19:16 INFO web[o.s.s.e.CoreExtensionStopper] Stopping Governance

2020.08.20 20:19:16 INFO web[o.s.s.e.CoreExtensionStopper] Stopping Governance (done) | time=0ms

SBSA-cobol-custom-rules.buildlog.txt (7.21 KB)

Hi Pierre, not sure if you saw my response regarding the other error I’m getting after adding the custom rules jar file?
Do you have any ideas how to solve it , any suggestion would be appreciated.

@ChiefShole Sorry, I think you shouldn’t expect people on this community forum to guide through every problem you get while developing a custom plugin. This is not a trivial task and you definitely need a Java developer to work with you.

The message you get contains a Java stacktrace which starts with:

java.lang.IllegalStateException: Resource not found: /org/sonar/l10n/cobol/rules/cobol/GetmainCommandUsage.html
  at com.mycompany.cobol.sample.CobolCustomCheckRepository.loadResource(CobolCustomCheckRepository.java:98)
  at com.mycompany.cobol.sample.CobolCustomCheckRepository.lambda$2(CobolCustomCheckRepository.java:79)

If you look at the code of CobolCustomCheckRepository, you should understand that it tries to load an HTML description for each custom rule and that should therefore provide one.

Hi Pierre,

Apologies , I do understand.

But the guidance you provided will really assist , I will engage my Developer on this

Appreciate the help.

Regards

Chief