Sonar启动报错分析
sonar启动,后台报错如下:
?
ERROR?jruby.rack?-?Error:?application?initialization?failed
org.jruby.rack.RackInitializationException:?java.lang.NullPointerException:?null
????from?org/sonar/server/ui/JRubyFacade.java:447:in?`getServerHome'
????from?/usr/local/tomcat/temp/0-sonar/WEB-INF/config/environment.rb:52:in?`(root)'
????from?/usr/local/tomcat/temp/0-sonar/WEB-INF/gems/gems/rails-2.3.14/lib/initializer.rb:111:in?`run'
????from?/usr/local/tomcat/temp/0-sonar/WEB-INF/config/environment.rb:32:in?`(root)'
????from?org/jruby/RubyKernel.java:1058:in?`load'
????from?/usr/local/tomcat/temp/0-sonar/WEB-INF/config/environment.rb:23:in?`load_environment'
????from?/usr/local/java/apache-tomcat-7.0.23/work/Catalina/localhost/sonar/loader/jruby/rack/rails_booter.rb:65:in?`load_environment'
????from?<script>:1:in?`(root)'
????at?org.jruby.rack.DefaultRackApplicationFactory$4.init(DefaultRackApplicationFactory.java:231)?~[jruby-rack-1.1.10.jar:na]
????at?org.jruby.rack.DefaultRackApplicationFactory.getApplication(DefaultRackApplicationFactory.java:58)?~[jruby-rack-1.1.10.jar:na]
????at?org.jruby.rack.SharedRackApplicationFactory.init(SharedRackApplicationFactory.java:33)?~[jruby-rack-1.1.10.jar:na]
????at?org.jruby.rack.RackServletContextListener.contextInitialized(RackServletContextListener.java:48)?~[jruby-rack-1.1.10.jar:na]
????at?org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4765)?[catalina.jar:7.0.23]
????at?org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5260)?[catalina.jar:7.0.23]
????at?org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)?[catalina.jar:7.0.23]
????at?org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:866)?[catalina.jar:7.0.23]
????at?org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:842)?[catalina.jar:7.0.23]
????at?org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)?[catalina.jar:7.0.23]
????at?org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:958)?[catalina.jar:7.0.23]
????at?org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1599)?[catalina.jar:7.0.23]
????at?java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)?[na:1.6.0_35]
????at?java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)?[na:1.6.0_35]
????at?java.util.concurrent.FutureTask.run(FutureTask.java:138)?[na:1.6.0_35]
????at?java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)?[na:1.6.0_35]
????at?java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)?[na:1.6.0_35]
????at?java.lang.Thread.run(Thread.java:680)?[na:1.6.0_35]
org.jruby.exceptions.RaiseException:?Native?Exception:?'class?java.lang.NullPointerException';?Message:?null;?StackTrace:?java.lang.NullPointerException
????at?org.sonar.server.ui.JRubyFacade.get(JRubyFacade.java:84)
????at?org.sonar.server.ui.JRubyFacade.getServerHome(JRubyFacade.java:447)
????at?org.sonar.server.ui.JRubyFacade.get(JRubyFacade.java:84)?~[JRubyFacade.class:na]
????at?org.sonar.server.ui.JRubyFacade.getServerHome(JRubyFacade.java:447)?~[JRubyFacade.class:na]
?Caused?by:?java.lang.NullPointerException:?null
????...?2?common?frames?omitted
?
将Sonar目录删除导致。
解决方法:重新打war包,部署到tomcat中,重启即可(原打包目录不能删除)
参考:http://stackoverflow.com/questions/13412527/sonar-throws-exception-when-starting-on-tomcat-6-running-on-os-x-server
?
举例说明:
下载sonar,解压到D:\download目录下,如下图:
?
双击sonar/war/build-war.bat打war包,将此war包部署到tomcat启动即可。
此处需要注意:D:\download\sonar-3.6?文件夹不能删除,否则启动sonar工程报错!!
?
添加语言包后,启动报错分析:
下载安装?sonar-l10n-zh-plugin-1.4.jar?语言包(http://docs.codehaus.org/display/SONAR/Chinese+Pack),重新打包部署后,后台报错如下:
?
Error?in?Sonar.log?:?2012.10.25?14:39:15?INFO?org.sonar.INFO?Register?rules?[squid/java]...2012.10.25?14:39:15?ERROR?o.s.s.p.Platform?The?following?rule?(repository:?squid)?must?have?a?description:?Rule[id=<null>,name=<null>,key=ParsingError,configKey=ParsingError,plugin=squid,enabled=true,severity=MAJOR,cardinality=SINGLE]org.sonar.api.utils.SonarException:?The?following?rule?(repository:?squid)?must?have?a?description:?Rule[id=<null>,name=<null>,key=ParsingError,configKey=ParsingError,plugin=squid,enabled=true,severity=MAJOR,cardinality=SINGLE]at?org.sonar.server.startup.RegisterRules.validateRule(RegisterRules.java:131)?~[classes/:na]at?org.sonar.server.startup.RegisterRules.registerRepository(RegisterRules.java:103)?~[classes/:na]at...
?
(可参考http://jira.codehaus.org/browse/SONAR-3910)
解决方法比较简单:
将?extensions\plugins\?目录下的jar包全部删除,重新加入本地语言包后,重新打包部署即可。
?
有关sonar安装配置,可参考我的另一篇文章?http://allen-j-will.iteye.com/blog/1893351