规则的声纳名称[repository = xxx key = yyy]为空

时间:2016-11-16 09:09:00

标签: java sonarqube sonarqube-web

我正在为内部语言添加新的声纳规则。规则注册没问题,但是我从声纳-plugin-api-4.4获得了“无法启动服务器”错误。

填充规则的所有资源(名称,描述,级别,重要性,类别)。

附上一块日志。

java.lang.IllegalStateException: Name of rule [repository=datastage, key=SEQ003] is empty
at org.sonar.api.server.rule.RulesDefinition$NewRule.validate(RulesDefinition.java:682) ~[sonar-plugin-api-4.4.jar:na]
at org.sonar.api.server.rule.RulesDefinition$NewRule.access$900(RulesDefinition.java:516) ~[sonar-plugin-api-4.4.jar:na]
at org.sonar.api.server.rule.RulesDefinition$RepositoryImpl.<init>(RulesDefinition.java:454) ~[sonar-plugin-api-4.4.jar:na]
at org.sonar.api.server.rule.RulesDefinition$RepositoryImpl.<init>(RulesDefinition.java:444) ~[sonar-plugin-api-4.4.jar:na]
at org.sonar.api.server.rule.RulesDefinition$Context.registerRepository(RulesDefinition.java:338) ~[sonar-plugin-api-4.4.jar:na]
at org.sonar.api.server.rule.RulesDefinition$Context.access$500(RulesDefinition.java:304) ~[sonar-plugin-api-4.4.jar:na]
at org.sonar.api.server.rule.RulesDefinition$NewRepositoryImpl.done(RulesDefinition.java:423) ~[sonar-plugin-api-4.4.jar:na]
at org.sonar.server.rule.DeprecatedRulesDefinition.define(DeprecatedRulesDefinition.java:106) ~[DeprecatedRulesDefinition.class:na]
at org.sonar.server.rule.RuleDefinitionsLoader.load(RuleDefinitionsLoader.java:45) ~[RuleDefinitionsLoader.class:na]
at org.sonar.server.rule.RegisterRules.start(RegisterRules.java:99) ~[RegisterRules.class:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_101]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_101]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_101]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_101]
at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:110) ~[picocontainer-2.14.3.jar:na]
at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.start(ReflectionLifecycleStrategy.java:89) ~[picocontainer-2.14.3.jar:na]
at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84) ~[picocontainer-2.14.3.jar:na]
at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169) ~[picocontainer-2.14.3.jar:na]
at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132) ~[picocontainer-2.14.3.jar:na]
at org.picocontainer.behaviors.Stored.start(Stored.java:110) ~[picocontainer-2.14.3.jar:na]
at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1015) ~[picocontainer-2.14.3.jar:na]
at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1008) ~[picocontainer-2.14.3.jar:na]
at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:766) ~[picocontainer-2.14.3.jar:na]
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:91) ~[sonar-plugin-api-4.4.jar:na]
at org.sonar.server.platform.ServerComponents$1.doPrivileged(ServerComponents.java:691) ~[ServerComponents$1.class:na]
at org.sonar.server.user.DoPrivileged.execute(DoPrivileged.java:43) ~[DoPrivileged.class:na]
at org.sonar.server.platform.ServerComponents.executeStartupTasks(ServerComponents.java:687) ~[ServerComponents.class:na]
at org.sonar.server.platform.Platform.executeStartupTasks(Platform.java:126) ~[Platform.class:na]
at org.sonar.server.platform.Platform.startLevel34Containers(Platform.java:122) ~[Platform.class:na]
at org.sonar.server.platform.Platform.doStart(Platform.java:81) ~[Platform.class:na]
at org.sonar.server.platform.PlatformServletContextListener.contextInitialized(PlatformServletContextListener.java:54) ~[PlatformServletContextListener.class:na]
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939) [tomcat-embed-core-7.0.42.jar:7.0.42]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434) [tomcat-embed-core-7.0.42.jar:7.0.42]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-7.0.42.jar:7.0.42]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) [tomcat-embed-core-7.0.42.jar:7.0.42]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) [tomcat-embed-core-7.0.42.jar:7.0.42]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_101]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_101]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_101]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_101]

2 个答案:

答案 0 :(得分:1)

当我尝试使用添加到pmd插件的自定义规则运行Jenkins作业进行Sonar分析时,我遇到了类似的错误。

11:20:28 INFO: PMD configuration: /u01/home/app/jenkins/jobs/CMTasks/jobs/SodimacSonarMaster/workspace/.sonar/pmd.xml
11:20:28 net.sourceforge.pmd.RuleSetNotFoundException: Can't find resource 'pmdAtgRuleset.xml' for rule 'ServiceLocalParameterInLogging'.  Make sure the resource is a     valid file or URL and is on the CLASSPATH. Here's the current classpath: /u01/home/app/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/sonarScanner/lib/    sonar-scanner-cli-2.8.jar
11:20:28    at net.sourceforge.pmd.RuleSetReferenceId.getInputStream(RuleSetReferenceId.java:315)
11:20:28    at net.sourceforge.pmd.RuleSetFactory.createRuleSet(RuleSetFactory.java:164)
11:20:28    at net.sourceforge.pmd.RuleSetFactory.createRule(RuleSetFactory.java:182)
11:20:28    at net.sourceforge.pmd.RuleSetFactory.parseRuleReferenceNode(RuleSetFactory.java:468)
11:20:28    at net.sourceforge.pmd.RuleSetFactory.parseRuleNode(RuleSetFactory.java:266)
11:20:28    at net.sourceforge.pmd.RuleSetFactory.parseRuleSetNode(RuleSetFactory.java:219)
...

要解决此问题,我将 pmdCustomRuleset.jar 复制到pmd-sonar-plugin.jar库路径 META-INF / lib / ,然后重新启动Sonar。< / p>

答案 1 :(得分:1)

我在基于 java-custom-rules-example 模板创建自定义规则时遇到了这个问题,如此 github 中所示。 此异常是通过简单地运行单元测试触发的,甚至在将其部署到声纳服务器之前也是如此。

我解决了这个问题,创建了缺失的 jsonhtml 文件来填充我的规则的元数据。 在此存储库中,它们位于 resources/ 文件夹内。

在那之后,我没有记录器遇到这个问题。 :)