7

I'm developing a plugin for SonarQube 4.5.4 / 5.0.1. I would like to use sonar-dev plugin to upload a JAR file and quickly restart SQ server. Plugin uses REST API (/api/system/restart), which is enabled by setting sonar.dev=true property.

Here's config:

<plugin>
    <groupId>org.codehaus.sonar</groupId>
    <artifactId>sonar-dev-maven-plugin</artifactId>
    <version>1.8</version>
    <configuration>
        <sonarHome>F:\sonarqube-5.1\sonarqube-5.1</sonarHome>
    </configuration>
</plugin>

The problem is that server crashes after each restart attempt and I have to restart it manually, which is frustrating and drains my productivity. Here's stacktrace that is returned on each following request after "restart".

org.jruby.exceptions.RaiseException: (NoMethodError) undefined method `controllers' for nil:NilClass
    at org.jruby.RubyKernel.method_missing(org/jruby/RubyKernel.java:255)
    at RUBY.method_missing(F:/sonarqube-5.1/sonarqube-5.1/web/WEB-INF/gems/gems/activesupport-2.3.15/lib/active_support/whiny_nil.rb:52)
    at RUBY.add_java_ws_routes(F:/sonarqube-5.1/sonarqube-5.1/web/WEB-INF/config/../lib/java_ws_routing.rb:34)
    at RUBY.reload(F:/sonarqube-5.1/sonarqube-5.1/web/WEB-INF/config/../lib/java_ws_routing.rb:58)
    at RUBY.reload_application(F:/sonarqube-5.1/sonarqube-5.1/web/WEB-INF/gems/gems/actionpack-2.3.15/lib/action_controller/dispatcher.rb:58)
    at RUBY.run(F:/sonarqube-5.1/sonarqube-5.1/web/WEB-INF/gems/gems/actionpack-2.3.15/lib/action_controller/reloader.rb:42)
    at RUBY.call(F:/sonarqube-5.1/sonarqube-5.1/web/WEB-INF/gems/gems/actionpack-2.3.15/lib/action_controller/dispatcher.rb:108)
    at RUBY.serve_rails(file:/F:/sonarqube-5.1/sonarqube-5.1/lib/server/jruby-rack-1.1.13.2.jar!/rack/adapter/rails.rb:34)
    at RUBY.call(file:/F:/sonarqube-5.1/sonarqube-5.1/lib/server/jruby-rack-1.1.13.2.jar!/rack/adapter/rails.rb:39)
    at RUBY.call(file:/F:/sonarqube-5.1/sonarqube-5.1/lib/server/jruby-rack-1.1.13.2.jar!/rack/handler/servlet.rb:22)

And here's what happens in logs starting from line 71.

According to @Simon Brandhof, it may be connected with class loader, that locks files. Any clue or workaround be be much appreciated.

Morten Kristensen
  • 7,412
  • 4
  • 32
  • 52
Michal Chudy
  • 1,883
  • 2
  • 21
  • 41
  • These seems to be related: http://stackoverflow.com/questions/11273303/java-classloader-dilemma-with-locked-jars and http://stackoverflow.com/questions/3216780/problem-reloading-a-jar-using-urlclassloader – Sergey Jun 08 '15 at 08:21

1 Answers1

6

The Java plugin seems to lock its classloader. Uninstalling it, by deleting extensions/plugins/sonar-java-plugin-3.0.jar, should fix the issue.

Igor Popov
  • 9,795
  • 7
  • 55
  • 68
Simon Brandhof
  • 5,137
  • 1
  • 21
  • 28
  • Hey, it worked. However I had to change scope of `java-squid:3.2` dependency to `compile`, which I previously had set to `provided`. My package weight changed from `29KB` to `2.4MB`, because bunch of other libraries were included also. (transitive deps?) Is it the way to go? Will it work, when SQ will have different versions of the same `java-squid` library from different plugins? – Michal Chudy Jun 05 '15 at 13:30
  • Moreover, I just learned that my plugin relies on Java plugin, since it adds couple of extra rules. Therefore, my plugin does not work without it. :-) – Michal Chudy Jun 05 '15 at 19:07
  • 1
    It doesn't really help in my particular case, since I'm dependent on that plugin, but it solves the issue itself. Ticket should be raised to fix java-plugin. Thanks for effort! For curious ones, I decided to go with unit test driven plugin development to speed up and it works well. No need for server during development. – Michal Chudy Jun 08 '15 at 16:11