Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-7914

Patch to get Sonar plugin also working with Jonas

XMLWordPrintable

    • Icon: Patch Patch
    • Resolution: Fixed
    • Icon: Minor Minor
    • sonar-plugin
    • None
    • Hudson 1.382 - JDK Sun 1.6_018
      Hudson is running into Jonas (http://wiki.jonas.ow2.org/).
      Sonar plugin: 1.5 and 1.6-SNAPSHOT

      Hi,
      I succeed to run Hudson in Jonas Application Server (http://wiki.jenkins-ci.org/display/JENKINS/Jonas). Adding the sonar plugin lead to the following error:

      2010-10-26 16:44:04,519 : J2EEServer.__info : JOnAS AS v5.1.4 named 'jonas' RUNNING
      2010-10-26 16:44:04,925 : Hudson$4.onAttained : Started initialization
      2010-10-26 16:44:34,691 : Hudson$4.onAttained : Listed all plugins
      2010-10-26 16:44:34,722 : BackupPluginImpl.loadConfiguration : Loading configuration...
      2010-10-26 16:44:34,722 : BackupPersistence.loadConfig : Config file not found.
      2010-10-26 16:44:34,879 : Hudson$4.onAttained : Prepared all plugins
      2010-10-26 16:44:34,957 : Hudson$4.onAttained : Started all plugins
      2010-10-26 16:44:34,957 : Hudson$4.onAttained : Augmented all extensions
      2010-10-26 16:44:39,785 : Hudson$4.onAttained : Loaded all jobs
      2010-10-26 16:44:41,613 : ExtensionFinder$Sezpoz.find : Failed to load hudson.plugins.sonar.SonarPublisher$DescriptorImpl
      java.lang.InstantiationException: java.lang.LinkageError: loader (instance of java/net/URLClassLoader): attempted duplicate class definition for name: "hudson/plugins/sonar/SonarPublisher"
      at net.java.sezpoz.IndexItem.instance(IndexItem.java:180)
      at hudson.ExtensionFinder$Sezpoz.find(ExtensionFinder.java:156)
      at hudson.ExtensionFinder._find(ExtensionFinder.java:92)
      at hudson.ExtensionList.load(ExtensionList.java:259)
      at hudson.ExtensionList.ensureLoaded(ExtensionList.java:216)
      at hudson.ExtensionList.getComponents(ExtensionList.java:124)
      at hudson.DescriptorExtensionList.load(DescriptorExtensionList.java:157)
      at hudson.ExtensionList.ensureLoaded(ExtensionList.java:216)
      at hudson.ExtensionList.size(ExtensionList.java:132)
      at java.util.AbstractCollection.isEmpty(AbstractCollection.java:69)
      at hudson.model.labels.LabelAtom.updateTransientActions(LabelAtom.java:103)
      at hudson.model.labels.LabelAtom.load(LabelAtom.java:175)
      at hudson.model.Hudson.getLabelAtom(Hudson.java:1420)
      at hudson.model.Hudson.getSelfLabel(Hudson.java:2146)
      at hudson.model.Node.getAssignedLabels(Node.java:191)
      at hudson.model.Hudson$13.run(Hudson.java:2205)
      at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:146)
      at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:259)
      at hudson.model.Hudson$3.runTask(Hudson.java:691)
      at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:187)
      at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:94)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:619)
      Caused by: java.lang.LinkageError: loader (instance of java/net/URLClassLoader): attempted duplicate class definition for name: "hudson/plugins/sonar/SonarPublisher"
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
      at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
      at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
      at hudson.plugins.sonar.SonarPublisher$DescriptorImpl.<init>(SonarPublisher.java:443)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
      at java.lang.Class.newInstance0(Class.java:355)
      at java.lang.Class.newInstance(Class.java:308)
      at net.java.sezpoz.IndexItem.instance(IndexItem.java:168)
      ... 23 more
      2010-10-26 16:44:42,175 : Hudson$4.onAttained : Completed initialization
      2010-10-26 16:44:43,347 : TcpSlaveAgentListener.<init> : JNLP slave agent listener started

      To avoid this error, I've made a little change, calling the no arg constructor:

      SonarPublisher.java
      ...
        @Extension
        public static final class DescriptorImpl extends BuildStepDescriptor<Publisher> {
      
          @CopyOnWrite
          private volatile SonarInstallation[] installations = new SonarInstallation[0]; //NOSONAR
      
          public DescriptorImpl() {
            //Old call: super(SonarPublisher.class);    
            super();
            load();
          }
      ...
      

      Hudson and the sonar plugin are working fine. I don't know what is the difference between the two constructor, but other plugins also use the no arg constructor (like svn-tag). If it's ok for you, could you include this change into the next release of the sonar plugin ?

      Thanks

            godin godin
            o_orand o_orand
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: